public static AlertProviderItemRespObj LoadAlertProviderItems(AlertProviderItemSearchObj regObj, string username)
        {
            var response = new AlertProviderItemRespObj
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new APIResponseMessage(),
                },
            };

            try
            {
                var apiResponse = new APIHelper(APIEndpoints.LOAD_ALERT_PROVIDER_ITEMS_ENDPOINT, username, Method.POST).ProcessAPI <AlertProviderItemSearchObj, AlertProviderItemRespObj>(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 ActionResult _ProviderItemView(int providerId)
        {
            try
            {
                ViewBag.Error = "";
                var userData = MvcApplication.GetUserData(User.Identity.Name);
                if (userData == null || userData.UserId < 1)
                {
                    ViewBag.Error = "Session Has Expired! Please Re-Login";
                    return(View(new List <AlertProviderItemObj>()));
                }
                if (Session["_AlertProviderItemList_" + providerId] is List <AlertProviderItemObj> mylist && mylist.Any())
                {
                    return(View(mylist));
                }

                var searchObj = new AlertProviderItemSearchObj
                {
                    AdminUserId         = userData.UserId,
                    AlertProviderItemId = 0,
                    AlertProviderId     = providerId,
                    AlertItemId         = 0,
                    Status = 0
                };

                var retVal = AlertProviderItemService.LoadAlertProviderItems(searchObj, userData.Username);
                if (retVal?.Status == null)
                {
                    ViewBag.Error = "Alert Provider Item list is empty!";
                    return(View(new List <AlertProviderItemObj>()));
                }

                if (!retVal.Status.IsSuccessful)
                {
                    ViewBag.Error = string.IsNullOrEmpty(retVal.Status.Message.FriendlyMessage)
                            ? " Alert Provider Item list is empty!"
                            : retVal.Status.Message.FriendlyMessage;
                    return(View(new List <AlertProviderItemObj>()));
                }
                if (retVal.AlertProviderItems == null || !retVal.AlertProviderItems.Any())
                {
                    ViewBag.Error = "Alert Provider Item list is empty!";
                    return(View(new List <AlertProviderItemObj>()));
                }

                //Order By AlertProviderItem Name
                var AlertProviderItems = retVal.AlertProviderItems.OrderBy(m => m.AlertProviderName).ToList();
                Session["_AlertProviderItemList_" + providerId] = AlertProviderItems;

                return(View(retVal.AlertProviderItems));
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Unable to load Users' list! Please try again later";
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new List <AlertProviderItemObj>()));
            }
        }