public ActionResult Create(CrudCustomerDto customer, ICreateService service) { if (!ModelState.IsValid) //model errors so return immediately return View(customer); var response = service.Create(customer); if (response.IsValid) { TempData["message"] = response.SuccessMessage + " You must now assign a password to this customer."; return RedirectToAction("NotCustomers"); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, customer); return View(customer); }
public ActionResult Create(CrudCustomerDto customer, ICreateService service) { if (!ModelState.IsValid) { //model errors so return immediately return(View(customer)); } var response = service.Create(customer); if (response.IsValid) { TempData["message"] = response.SuccessMessage + " You must now assign a password to this customer."; return(RedirectToAction("NotCustomers")); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, customer); return(View(customer)); }
public ActionResult Edit(CrudCustomerDto customer, IUpdateService service) { if (!ModelState.IsValid) { //model errors so return immediately service.ResetDto(customer); return(View(customer)); } var response = service.Update(customer); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return(RedirectToAction(customer.HasBoughtBefore ? "Index" : "NotCustomers")); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, customer); return(View(customer)); }
public ActionResult Edit(CrudCustomerDto customer, IUpdateService service) { if (!ModelState.IsValid) { //model errors so return immediately service.ResetDto(customer); return View(customer); } var response = service.Update(customer); if (response.IsValid) { TempData["message"] = response.SuccessMessage; return RedirectToAction(customer.HasBoughtBefore ? "Index" : "NotCustomers"); } //else errors, so copy the errors over to the ModelState and return to view response.CopyErrorsToModelState(ModelState, customer); return View(customer); }