public JsonResult ProcessAddDepenDentLKPRequest(RegExpenseLookupObj 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

                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 (string.IsNullOrEmpty(model.InclusionList) || model.InclusionList.Length < 0)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "No Item Selected" }));
                }

                if (string.IsNullOrEmpty(model.LookupName) || model.LookupName.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Lookup Name is required" }));
                }

                #endregion

                #region  Expense Lookup from service

                var searchObjLKP = new ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = -2
                };

                var retValLKP = ExpenseLookUpServices.LoadExpenseLookups(searchObjLKP, userData.Username);
                if (retValLKP?.Status == null && retValLKP.ExpenseLookups == null)
                {
                }

                var LKPList = retValLKP.ExpenseLookups
                              .Where(m => m.LookupName.Trim().ToLower().ToStandardHash()
                                     == model.LookupName.ToString().Trim().ToLower().ToStandardHash())
                              .OrderBy(m => m.ExpenseLookupId).ToList();

                if (LKPList == null || !LKPList.Any())
                {
                    return(Json(new { IsSuccessful = false, IsAuthenticated = true }));
                }

                var thisClientProdLKP = LKPList.SingleOrDefault(m => m.ClientId == model.ClientId && m.ProductId == model.ProductId);

                if (thisClientProdLKP == null || thisClientProdLKP.ExpenseLookupId < 1)
                {
                    return(Json(new { IsSuccessful = false, IsAuthenticated = true, Error = "Something went wrong" }));
                }

                thisClientProdLKP.InclusionList = thisClientProdLKP.InclusionList.TrimStart(',').TrimEnd(',');

                string[] NewLKPIdsArray;

                string[] addedLkpIds = thisClientProdLKP.InclusionList.Trim().Split(',');

                string[] modelLKPIds = model.InclusionList.Trim().Split(',');

                NewLKPIdsArray = addedLkpIds.Concat(modelLKPIds).ToArray();

                HashSet <string> newList = new HashSet <string>(NewLKPIdsArray);

                newList.UnionWith(addedLkpIds);
                string lkpIDtoAdd = string.Join(",", newList);



                #endregion

                #region Build Request Object

                var requestObj = new EditExpenseLookupObj
                {
                    ClientId            = model.ClientId,
                    ProductId           = model.ProductId,
                    AdminUserId         = userData.UserId,
                    ChannelCode         = thisClientProdLKP.ChannelCode,
                    ExclusionList       = " 10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001",
                    InclusionList       = lkpIDtoAdd,
                    IsEnabled           = thisClientProdLKP.IsEnabled,
                    LookupItem          = model.LookupItem,
                    LookupName          = model.LookupName,
                    RegisteredBy        = userData.UserId,
                    Status              = 1,
                    TimeStampRegistered = DateTime.Now.ToString("ddd-mmm-yyyy"),
                    ProductItemId       = thisClientProdLKP.ProductItemId,
                    ExpenseLookupId     = thisClientProdLKP.ExpenseLookupId,
                };

                #endregion

                #region Request and response validations

                var response = ExpenseLookUpServices.UpdateExpenseLookup(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 ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = -2
                };

                var retVal = ExpenseLookUpServices.LoadExpenseLookups(searchObj, userData.Username);
                if (retVal?.Status != null && retVal.ExpenseLookups != null)
                {
                    var ExpenseLookups = retVal.ExpenseLookups.OrderBy(m => m.ExpenseLookupId).ToList();
                    Session["_ExpenseLookupList_"] = ExpenseLookups;
                }


                #endregion

                ViewBag.ClientId      = model.ClientId;
                ViewBag.ProductId     = model.ProductId;
                ViewBag.ProductItemId = model.ProductItemId;

                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" }));
            }
        }
        public JsonResult ProcessEditExpenseLookupRequest(ExpenseLookupObj 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 Validation Checks
                var selExpenseLookup = Session["_CurrentSelExpenseLookup_"] as ExpenseLookupObj;
                if (selExpenseLookup == null || selExpenseLookup.ExpenseLookupId < 1)
                {
                    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.ExpenseLookupId < 1)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "ExpenseLookupId required" }));
                }

                if (string.IsNullOrEmpty(model.LookupName) || model.LookupName.Length < 2)
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Lookup Name is required" }));
                }
                if (!GenericVal.Validate(model, out var msg))
                {
                    return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = $"Validation Error Occurred! Detail: {msg}" }));
                }
                #endregion

                #region Build Requesr Object


                var passObj = new EditExpenseLookupObj()
                {
                    ClientId            = model.ClientId,
                    ProductId           = model.ProductId,
                    AdminUserId         = userData.UserId,
                    ChannelCode         = "Channel",
                    ExclusionList       = model.ExclusionList,
                    InclusionList       = model.InclusionList,
                    IsEnabled           = model.IsEnabled,
                    LookupItem          = model.LookupItem,
                    LookupName          = model.LookupName,
                    RegisteredBy        = 1,
                    Status              = 1,
                    TimeStampRegistered = DateTime.Now.ToString("ddd-mmm-yyyy"),
                    ExpenseLookupId     = model.ExpenseLookupId,
                    ProductItemId       = model.ProductItemId
                };


                #endregion

                #region Request and responses Validation checks

                var response = ExpenseLookUpServices.UpdateExpenseLookup(passObj, 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 course of study" : response.Status.Message.TechnicalMessage }));
                }

                Session["_CurrentSelExpenseLookup_"] = null;

                var searchObj = new ExpenseLookupSearchObj
                {
                    AdminUserId     = userData.UserId,
                    ExpenseLookupId = 0,
                    Status          = -2
                };

                var retVal = ExpenseLookUpServices.LoadExpenseLookups(searchObj, userData.Username);
                if (retVal?.Status != null && retVal.ExpenseLookups != null)
                {
                    var ExpenseLookups = retVal.ExpenseLookups.OrderBy(m => m.ExpenseLookupId).ToList();
                    Session["_ExpenseLookupList_"] = ExpenseLookups.Where(m => m.ProductId == model.ProductId && m.ClientId == model.ClientId && 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" }));
            }
        }