public ActionResult CreateSpouse(SpouseViewModel spouseViewModel, string url) { if (spouseViewModel == null) { throw new ArgumentNullException(nameof(spouseViewModel)); } if (!ModelState.IsValid) { var viewmodel = this.employeeService.GetSpouseCreateView(spouseViewModel, ""); return(this.View("CreateSpouse", viewmodel)); } var processingMessage = this.employeeService.ProcessSpouseCreateView(spouseViewModel); if (!string.IsNullOrEmpty(processingMessage)) { var viewmodel = this.employeeService.GetSpouseCreateView(spouseViewModel, processingMessage); return(View("CreateSpouse", viewmodel)); } processingMessage = string.Format("{0} Added a Spouse", spouseViewModel.SpouseName); return(Redirect(url + "&message=" + processingMessage)); }
public ActionResult EditSpouse(SpouseViewModel spouseViewModel, string url) { if (spouseViewModel == null) { throw new ArgumentNullException(nameof(spouseViewModel)); } if (!ModelState.IsValid) { var viewmodel = this.employeeService.GetSpouseCreateView(spouseViewModel, ""); return(this.View("/Profile/Index?message=" + viewmodel)); } var processingMessage = this.employeeService.ProcessSpouseEditView(spouseViewModel); //return View("EditSpouse", processingMessage); if (!string.IsNullOrEmpty(processingMessage)) { var viewmodel = this.employeeService.GetSpouseCreateView(spouseViewModel, processingMessage); return(View("EditSpouse", viewmodel)); } processingMessage = string.Format("{0} Updated", spouseViewModel.SpouseName, "Successfully"); return(Redirect(url + "&message=" + processingMessage)); }
public ISpouseViewModel CreateSpouseView(int employeeId, string message) { if (employeeId <= 0) { throw new ArgumentNullException(nameof(employeeId)); } var viewModel = new SpouseViewModel { EmployeeId = employeeId, ProcessingMessage = message }; return(viewModel); }
/// <summary> /// Edits the spouse view. /// </summary> /// <param name="spouseModel">The spouse model.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">spouseModel</exception> public ISpouseViewModel EditSpouseView(ISpouseModel spouseModel) { if (spouseModel == null) { throw new ArgumentNullException(nameof(spouseModel)); } var viewModel = new SpouseViewModel { SpouseId = spouseModel.SpouseId, SpouseName = spouseModel.SpouseName, EmployeeId = spouseModel.EmployeeId, Email = spouseModel.Email, Address = spouseModel.Address, DateCreated = spouseModel.DateCreated, DateModified = spouseModel.DateModified, DateOfBirth = spouseModel.DateOfBirth, IsActive = spouseModel.IsActive, IsApproved = spouseModel.IsApproved, Mobile = spouseModel.Mobile, ProcessingMessage = string.Empty }; return(viewModel); }