public ActionResult Save(Customer customer) { if (!ModelState.IsValid) { NewCustomerViewModel viewModel = new NewCustomerViewModel() { Customer = customer, MembershipTypes = _repo.GetMembershipTypes() }; return(View("CustomerForm", viewModel)); } if (customer.Id == 0) { _repo.CreateCustomer(customer); } else { _repo.UpdateCustomer(customer); } return(RedirectToAction("Index", "Customer")); }
public Customer CreateCustomer(Customer customer) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } _repo.CreateCustomer(customer); return(customer); }