public static AlertTypeRespObj LoadAlertTypes(AlertTypeSearchObj regObj, string username) { var response = new AlertTypeRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage(), }, }; try { var apiResponse = new APIHelper(APIEndpoints.LOAD_ALERT_TYPES_ENDPOINT, username, Method.POST).ProcessAPI <AlertTypeSearchObj, AlertTypeRespObj>(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 Index() { try { 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 <AlertTypeObj>())); } if (Session["_AlertTypeList_"] is List <AlertTypeObj> mylist && mylist.Any()) { return(View(mylist)); } var searchObj = new AlertTypeSearchObj { AdminUserId = userData.UserId, AlertTypeId = 0, Status = 0 }; var retVal = AlertTypeService.LoadAlertTypes(searchObj, userData.Username); if (retVal?.Status == null) { ViewBag.Error = "Alert Type list is empty!"; return(View(new List <AlertTypeObj>())); } if (!retVal.Status.IsSuccessful) { ViewBag.Error = string.IsNullOrEmpty(retVal.Status.Message.FriendlyMessage) ? " Alert Type list is empty!" : retVal.Status.Message.FriendlyMessage; return(View(new List <AlertTypeObj>())); } if (retVal.AlertTypes == null || !retVal.AlertTypes.Any()) { ViewBag.Error = "Alert Type list is empty!"; return(View(new List <AlertTypeObj>())); } //Order By AlertType Name var AlertTypes = retVal.AlertTypes.OrderBy(m => m.AlertProviderId).ToList(); Session["_AlertTypeList_"] = AlertTypes; return(View(AlertTypes)); } catch (Exception ex) { ViewBag.Error = ex.Message; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new List <AlertTypeObj>())); } }