public IActionResult AddMasterEmployeeType() { try { AddMasterEmployeeTypeViewModel objAddMasterEmployeeTypeViewModel = new AddMasterEmployeeTypeViewModel(); objAddMasterEmployeeTypeViewModel.Mode = CommonFunction.Mode.SAVE; objAddMasterEmployeeTypeViewModel.IsActive = true; objAddMasterEmployeeTypeViewModel.MasterEmployeeTypeId = CommonFunction.NextMasterId("ADMasterEmployeeType", apiBaseUrl); objAddMasterEmployeeTypeViewModel.MasterEmployeeTypeId = 0; objAddMasterEmployeeTypeViewModel.EmployeeTypeTitle = ""; objAddMasterEmployeeTypeViewModel.EmpTypCode = ""; objAddMasterEmployeeTypeViewModel.Remark = ""; //DropDownFillMethod(); //Return View doesn't make a new requests, it just renders the view return(View("~/Views/Master/MasterEmployeeType/AddMasterEmployeeType.cshtml", objAddMasterEmployeeTypeViewModel)); } 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 ViewMasterEmployeeType(long MasterEmployeeTypeId) { try { AddMasterEmployeeTypeViewModel objAddMasterEmployeeTypeViewModel = null; string endpoint = apiBaseUrl + "MasterEmployeeTypes/" + MasterEmployeeTypeId; Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint); if (HttpGetResponse != null) { objAddMasterEmployeeTypeViewModel = JsonConvert.DeserializeObject <AddMasterEmployeeTypeViewModel>(HttpGetResponse.Result); } else { objAddMasterEmployeeTypeViewModel = new AddMasterEmployeeTypeViewModel(); ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } //DropDownFillMethod(); objAddMasterEmployeeTypeViewModel.Mode = CommonFunction.Mode.UPDATE; return(View("~/Views/Master/MasterEmployeeType/AddMasterEmployeeType.cshtml", objAddMasterEmployeeTypeViewModel)); } 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 SaveMasterEmployeeType(AddMasterEmployeeTypeViewModel objAddMasterEmployeeTypeViewModel) { try { objAddMasterEmployeeTypeViewModel.EnterById = 1; objAddMasterEmployeeTypeViewModel.EnterDate = DateTime.Now; objAddMasterEmployeeTypeViewModel.ModifiedById = 1; objAddMasterEmployeeTypeViewModel.ModifiedDate = DateTime.Now; if (objAddMasterEmployeeTypeViewModel.IsActive == null) { objAddMasterEmployeeTypeViewModel.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 + "MasterEmployeeTypes"; Task <string> HttpPostResponse = null; if (objAddMasterEmployeeTypeViewModel.Mode == CommonFunction.Mode.SAVE) { HttpPostResponse = CommonFunction.PostWebAPI(endpoint, objAddMasterEmployeeTypeViewModel); //Notification Message //Session is used to store object HttpContext.Session.SetObjectAsJson("GlobalMessage", CommonFunction.GlobalMessage(1, 2, 4, "Master EmployeeType", "Master EmployeeType Insert Successfully!", "")); } else if (objAddMasterEmployeeTypeViewModel.Mode == CommonFunction.Mode.UPDATE) { endpoint = apiBaseUrl + "MasterEmployeeTypes/" + objAddMasterEmployeeTypeViewModel.MasterEmployeeTypeId; HttpPostResponse = CommonFunction.PutWebAPI(endpoint, objAddMasterEmployeeTypeViewModel); //Notification Message //Session is used to store object HttpContext.Session.SetObjectAsJson("GlobalMessage", CommonFunction.GlobalMessage(1, 2, 4, "Master EmployeeType", "Master EmployeeType Update Successfully!", "")); } if (HttpPostResponse != null) { objAddMasterEmployeeTypeViewModel = JsonConvert.DeserializeObject <AddMasterEmployeeTypeViewModel>(HttpPostResponse.Result); _logger.LogInformation("Database Insert/Update: ");//+ JsonConvert.SerializeObject(objAddMasterEmployeeTypeViewModel)); ; return(RedirectToAction("Index")); } else { //DropDownFillMethod(); ModelState.Clear(); ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); return(View("~/Views/Master/MasterEmployeeType/AddMasterEmployeeType.cshtml", objAddMasterEmployeeTypeViewModel)); } } 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/MasterEmployeeType/AddMasterEmployeeType.cshtml", objAddMasterEmployeeTypeViewModel)); } } 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()); }