public static ClientRegRespObj DeleteClient(DeleteClientObj regObj, string username) { var response = new ClientRegRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage(), }, }; try { var apiResponse = new APIHelper(APIEndpoints.DELETE_CLIENT_ENDPOINT, username, Method.POST).ProcessAPI <DeleteClientObj, ClientRegRespObj>(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 ProcessDeleteRequest(int ClientId) { 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 })); } if (ClientId < 1) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, Error = "Invalid / Empty Selection" })); } var previousClientList = Session["_ClientList_"] as List <ClientObj>; if (previousClientList == null) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = true })); } var thisItem = previousClientList.Find(m => m.ClientId == ClientId); if (thisItem == null || thisItem.ClientId < 1) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, Error = "Selected item does not exist in the collection" })); } var passObj = new DeleteClientObj { AdminUserId = userData.UserId, ClientId = ClientId }; var response = ClientService.DeleteClient(passObj, User.Identity.Name); if (!response.Status.IsSuccessful) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, Error = response.Status.Message.FriendlyMessage })); } return(Json(new { IsAuthenticated = true, IsSuccessful = true, 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" })); } }