using System.Collections.Generic;

namespace OnlineAssessment.Common
{
    public class ReturnResponse
    {
        public ReturnResponse()
        {

        }
        public ReturnResponse(string errMessage)
        {
            this.Result = errMessage;
        }

        public ReturnResponse(string errMessage, ReturnStatus status)
        {
            this.Result = errMessage == string.Empty ? new object() : errMessage;
            this.Status = status;
        }
        public object Result { get; set; }

        public ReturnStatus Status { get; set; }

        public static ReturnResponse GetSuccessStatus(dynamic obj)
        {
            ReturnResponse response = new ReturnResponse();
            ReturnStatus status = new ReturnStatus(((int)Message.Success).ToString(), Message.Success.ToString().ToUpper());

            response.Result = obj;
            response.Status = status;

            return response;
        }

        public static ReturnResponse GetSuccessStatus(dynamic obj, string successMessage)
        {
            ReturnResponse response = new ReturnResponse();
            ReturnStatus status = new ReturnStatus(((int)Message.Success).ToString(), successMessage);

            response.Result = obj;
            response.Status = status;

            return response;
        }

        public static ReturnResponse GetFailureStatus(string errMessage)
        {
            ReturnResponse response = new ReturnResponse();
            ReturnStatus status = new ReturnStatus(((int)Message.Failure).ToString(), errMessage);

            response.Result = new object();
            response.Status = status;

            return response;
        }


        public static ReturnResponse GetFailureStatus(int errCode, string errMessage)
        {
            ReturnResponse response = new ReturnResponse();
            ReturnStatus status = new ReturnStatus(((int)(Message)errCode).ToString(), errMessage);

            response.Result = new object();
            response.Status = status;

            return response;
        }

        public static ReturnResponse GetFailureStatus(List<string> errList)
        {
            ReturnResponse response = new ReturnResponse();
            ReturnStatus status = new ReturnStatus(((int)Message.Failure).ToString(), errList);

            response.Result = new object();
            response.Status = status;

            return response;
        }
    }
}
