public static RequestTypeSettingRegRespObj AddRequestTypeSetting(RegRequestTypeSettingObj regObj, string username)
        {
            var response = new RequestTypeSettingRegRespObj
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new APIResponseMessage(),
                },
            };

            try
            {
                var apiResponse = new APIHelper(APIEndpoints.ADD_REQUEST_TYPE_SETTINGS_ENDPOINT, username, Method.POST).ProcessAPI <RegRequestTypeSettingObj, RequestTypeSettingRegRespObj>(regObj, out var msg);
                if (msg.Code == 0 && string.IsNullOrEmpty(msg.TechMessage) && string.IsNullOrEmpty(msg.Message))
                {
                    return(apiResponse);
                }

                response.Status.Message.FriendlyMessage  = msg.Message;
                response.Status.Message.TechnicalMessage = msg.TechMessage;
                return(response);
            }
            catch (Exception ex)
            {
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.GetBaseException().Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                return(response);
            }
        }
        public JsonResult ProcessAddRequestTypeSettingRequest(RegRequestTypeSettingObj model)
        {
            try
            {
                #region Current User Session Check

                var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData();
                if (userData.UserId < 1)
                {
                    return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false }));
                }

                #endregion

                #region Model Validations Check

                if (model == null)
                {
                    return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false }));
                }

                if (model.ClientId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "client required " }));
                }

                if (model.ProductItemId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product Item required " }));
                }

                if (model.ProductId < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product required " }));
                }

                if (model.RequestType < 1)
                {
                    return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product required " }));
                }

                #endregion

                #region Check if Item Already Exist from Session


                var requestTypeSettingList = (List <RequestTypeSetting>)Session["_RequestTypeSettingList_"];
                if (requestTypeSettingList != null)
                {
                    if (requestTypeSettingList.Any(x => x.RequestType == model.RequestType &&
                                                   x.ClientId == model.ClientId &&
                                                   x.ProductId == model.ProductId &&
                                                   x.ProductItemId == model.ProductItemId))
                    {
                        return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Request Type Already Exist!" }));
                    }
                }

                #endregion

                #region Build Request Object

                var requestObj = new RegRequestTypeSettingObj
                {
                    ClientId             = model.ClientId,
                    ProductId            = model.ProductId,
                    AdminUserId          = userData.UserId,
                    Status               = 1,
                    ProductItemId        = model.ProductItemId,
                    AllowedTaskTimeSpan  = model.AllowedTaskTimeSpan,//Convert.ToInt32(UtilTools.CurrentTimeStamp()),
                    AmountAllowed        = model.AmountAllowed,
                    RequestType          = model.RequestType,
                    TimeElapseAction     = 1,//Convert.ToInt32(DateTime.Now.Day), //model.TimeElapseAction,
                    TimeStampRegistered  = UtilTools.CurrentTimeStamp(),
                    RequestFrequencyType = model.RequestFrequencyType,
                };

                #endregion

                #region Request and response validations checks

                var response = RequestTypeSettingServices.AddRequestTypeSetting(requestObj, userData.Username);
                if (response?.Status == null)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" }));
                }

                if (!response.Status.IsSuccessful)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = string.IsNullOrEmpty(response.Status.Message.TechnicalMessage) ? "Process Failed! Unable to add nomination Source" : response.Status.Message.TechnicalMessage }));
                }


                var searchObj = new RequestTypeSettingSearchObj
                {
                    AdminUserId          = userData.UserId,
                    RequestTypeSettingId = 0,
                    Status    = 1,
                    StartDate = "",
                    StopDate  = "",
                };

                var retVal = RequestTypeSettingServices.LoadRequestTypeSettings(searchObj, userData.Username);
                if (retVal?.Status != null && retVal.RequestTypeSettings != null)
                {
                    var RequestTypeSettings = retVal.RequestTypeSettings.OrderBy(m => m.RequestTypeSettingId).ToList();
                    Session["_RequestTypeSettingList_"] = RequestTypeSettings.Where(m => m.ClientId == model.ClientId &&
                                                                                    m.ProductId == model.ProductId &&
                                                                                    m.ProductItemId == model.ProductItemId).ToList();;
                }


                #endregion

                return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" }));
            }
            catch (Exception ex)
            {
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Process Error Occurred! Please try again later" }));
            }
        }