public ActionResult AddAddress(CrudCustomerAddressDto customerAddress, ICreateService service) { if (!ModelState.IsValid) //model errors so return immediately return View(customerAddress); var response = service.Create(customerAddress); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return RedirectToAction("Details", new { id = customerAddress.CustomerID }); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, customerAddress); return View(customerAddress); }
public ActionResult AddAddress(CrudCustomerAddressDto customerAddress, ICreateService service) { if (!ModelState.IsValid) { //model errors so return immediately return(View(customerAddress)); } var response = service.Create(customerAddress); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return(RedirectToAction("Details", new { id = customerAddress.CustomerID })); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, customerAddress); return(View(customerAddress)); }