public static AlertTypeRegRespObj UpdateAlertType(EditAlertTypeObj regObj, string username) { var response = new AlertTypeRegRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage(), }, }; try { var apiResponse = new APIHelper(APIEndpoints.UPDATE_ALERT_TYPE_ENDPOINT, username, Method.POST).ProcessAPI <EditAlertTypeObj, AlertTypeRegRespObj>(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 ProcessEditAlertTypeRequest(AlertTypeObj model) { try { 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 })); } var selAlertType = Session["_CurrentSelAlertType_"] as AlertTypeObj; if (selAlertType == null || selAlertType.AlertTypeId < 1) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false })); } if (model.AlertTypeId < 1) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid Selection" })); } if (string.IsNullOrEmpty(model.Title) || model.Title.Length < 2) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Invalid AlertType Name" })); } var passObj = new EditAlertTypeObj { AdminUserId = userData.UserId, Title = model.Title, AlertTypeId = selAlertType.AlertTypeId, Status = model.StatusVal ? 1 : 0, }; if (!GenericVal.Validate(model, out var msg)) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = $"Validation Error Occurred! Detail: {msg}" })); } var response = AlertTypeService.UpdateAlertType(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["_CurrentSelAlertType_"] = null; Session["_AlertTypeList_"] = null; 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" })); } }