public IActionResult AddMasterLoginType() { try { AddMasterLoginTypeViewModel objAddMasterLoginTypeViewModel = new AddMasterLoginTypeViewModel(); objAddMasterLoginTypeViewModel.Mode = CommonFunction.Mode.SAVE; objAddMasterLoginTypeViewModel.IsActive = true; objAddMasterLoginTypeViewModel.MasterLoginTypeId = CommonFunction.NextMasterId("ADMasterLoginType", apiBaseUrl); objAddMasterLoginTypeViewModel.MasterLoginTypeId = 0; objAddMasterLoginTypeViewModel.MasterLoginTypeTitle = ""; //DropDownFillMethod(); //Return View doesn't make a new requests, it just renders the view return(View("~/Views/Master/MasterLoginType/AddMasterLoginType.cshtml", objAddMasterLoginTypeViewModel)); } catch (Exception ex) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); string ErrorMessage = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message; _logger.LogError(ErrorMessage); return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName))); } return(new EmptyResult()); }
public IActionResult ViewMasterLoginType(long MasterLoginTypeId) { try { AddMasterLoginTypeViewModel objAddMasterLoginTypeViewModel = null; string endpoint = apiBaseUrl + "MasterLoginTypes/" + MasterLoginTypeId; Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint); if (HttpGetResponse != null) { objAddMasterLoginTypeViewModel = JsonConvert.DeserializeObject <AddMasterLoginTypeViewModel>(HttpGetResponse.Result); } else { objAddMasterLoginTypeViewModel = new AddMasterLoginTypeViewModel(); ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } //DropDownFillMethod(); objAddMasterLoginTypeViewModel.Mode = CommonFunction.Mode.UPDATE; return(View("~/Views/Master/MasterLoginType/AddMasterLoginType.cshtml", objAddMasterLoginTypeViewModel)); } catch (Exception ex) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); string ErrorMessage = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message; _logger.LogError(ErrorMessage); return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName))); } return(new EmptyResult()); }
public IActionResult SaveMasterLoginType(AddMasterLoginTypeViewModel objAddMasterLoginTypeViewModel) { try { objAddMasterLoginTypeViewModel.EnterById = 1; objAddMasterLoginTypeViewModel.EnterDate = DateTime.Now; objAddMasterLoginTypeViewModel.ModifiedById = 1; objAddMasterLoginTypeViewModel.ModifiedDate = DateTime.Now; if (objAddMasterLoginTypeViewModel.IsActive == null) { objAddMasterLoginTypeViewModel.IsActive = false; } var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); if (ModelState.IsValid) { string endpoint = apiBaseUrl + "MasterLoginTypes"; Task <string> HttpPostResponse = null; if (objAddMasterLoginTypeViewModel.Mode == CommonFunction.Mode.SAVE) { HttpPostResponse = CommonFunction.PostWebAPI(endpoint, objAddMasterLoginTypeViewModel); //Notification Message //Session is used to store object HttpContext.Session.SetObjectAsJson("GlobalMessage", CommonFunction.GlobalMessage(1, 2, 4, "Master LoginType", "Master LoginType Insert Successfully!", "")); } else if (objAddMasterLoginTypeViewModel.Mode == CommonFunction.Mode.UPDATE) { endpoint = apiBaseUrl + "MasterLoginTypes/" + objAddMasterLoginTypeViewModel.MasterLoginTypeId; HttpPostResponse = CommonFunction.PutWebAPI(endpoint, objAddMasterLoginTypeViewModel); //Notification Message //Session is used to store object HttpContext.Session.SetObjectAsJson("GlobalMessage", CommonFunction.GlobalMessage(1, 2, 4, "Master LoginType", "Master LoginType Update Successfully!", "")); } if (HttpPostResponse != null) { objAddMasterLoginTypeViewModel = JsonConvert.DeserializeObject <AddMasterLoginTypeViewModel>(HttpPostResponse.Result); _logger.LogInformation("Database Insert/Update: ");//+ JsonConvert.SerializeObject(objAddGenCodeTypeViewModel)); ; return(RedirectToAction("Index")); } else { //DropDownFillMethod(); ModelState.Clear(); ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); return(View("~/Views/Master/MasterLoginType/AddMasterLoginType.cshtml", objAddMasterLoginTypeViewModel)); } } else { ModelState.Clear(); if (ModelState.IsValid == false) { ModelState.AddModelError(string.Empty, "Validation error. Please contact administrator."); } //DropDownFillMethod(); //Return View doesn't make a new requests, it just renders the view return(View("~/Views/Master/MasterLoginType/AddMasterLoginType.cshtml", objAddMasterLoginTypeViewModel)); } } catch (Exception ex) { string ActionName = this.ControllerContext.RouteData.Values["action"].ToString(); string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); string ErrorMessage = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message; _logger.LogError(ErrorMessage); return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName))); } return(new EmptyResult()); }