public async Task <IActionResult> Edit(int id, string returnUrl = null) { if (String.IsNullOrEmpty(returnUrl)) { returnUrl = Request.Headers["Referer"].ToString(); } var vehicleType = await _vehicleTypeRepo.GetVehicleType(id); VehicleTypeViewModel vehicleTypeVM = VehicleTypeViewModelFactory.Edit(vehicleType, returnUrl); return(View("Edit", vehicleTypeVM)); }
public async Task <IActionResult> Edit([FromForm] VehicleTypeViewModel vehicleTypeVM) { if (ModelState.IsValid) { await _vehicleTypeRepo.UpdateVehicleType(vehicleTypeVM.VehicleType); TempData["message"] = "Your data has been updated successfully."; TempData["toasterType"] = ToasterType.success; return(RedirectToAction(nameof(Edit), new { id = vehicleTypeVM.VehicleType.Id, returnUrl = vehicleTypeVM.ReturnUrl })); } else { TempData["message"] = "A problem has been ocurred while updating your data."; TempData["toasterType"] = ToasterType.info; } return(View("Edit", VehicleTypeViewModelFactory.Edit(vehicleTypeVM.VehicleType, vehicleTypeVM.ReturnUrl))); }