public async Task <IActionResult> Edit(int id, string returnUrl = null) { if (String.IsNullOrEmpty(returnUrl)) { returnUrl = Request.Headers["Referer"].ToString(); } var visitType = await _visitTypeRepo.GetVisitType(id); VisitTypeViewModel visitTypeVM = VisitTypeViewModelFactory.Edit(visitType, returnUrl); return(View("Edit", visitTypeVM)); }
public async Task <IActionResult> Edit([FromForm] VisitTypeViewModel visitTypeVM) { if (ModelState.IsValid) { await _visitTypeRepo.UpdateVisitType(visitTypeVM.VisitType); TempData["message"] = "Your data has been updated successfully."; TempData["toasterType"] = ToasterType.success; return(RedirectToAction(nameof(Edit), new { id = visitTypeVM.VisitType.Id, returnUrl = visitTypeVM.ReturnUrl })); } else { TempData["message"] = "A problem has been ocurred while updating your data."; TempData["toasterType"] = ToasterType.info; } return(View("Edit", VisitTypeViewModelFactory.Edit(visitTypeVM.VisitType, visitTypeVM.ReturnUrl))); }