public async Task <IActionResult> Edit(int id, string returnUrl = null) { if (String.IsNullOrEmpty(returnUrl)) { returnUrl = Request.Headers["Referer"].ToString(); } var employeeDepartment = await _employeeDeparment.GetEmployeeDepartment(id); EmployeeDepartmentViewModel deparment = EmployeeDepartmentViewModelFactory.Edit(employeeDepartment, returnUrl); return(View("Edit", deparment)); }
public async Task <IActionResult> Edit([FromForm] EmployeeDepartmentViewModel employeeDepartmentVM) { if (ModelState.IsValid) { await _employeeDeparment.UpdateEmployeeDepartment(employeeDepartmentVM.EmployeeDepartment); TempData["message"] = "Your data has been updated successfully."; TempData["toasterType"] = ToasterType.success; return(RedirectToAction(nameof(Edit), new { id = employeeDepartmentVM.EmployeeDepartment.Id, returnUrl = employeeDepartmentVM.ReturnUrl })); } else { TempData["message"] = "A problem has been ocurred while updating your data."; TempData["toasterType"] = ToasterType.info; } return(View("Edit", EmployeeDepartmentViewModelFactory.Edit(employeeDepartmentVM.EmployeeDepartment, employeeDepartmentVM.ReturnUrl))); }