public ViewResult CustomerAdd() { CustomerDataView customerDV = new CustomerDataView() { Sexes = FakeDB.GetSelectListItemSex() }; return(View(customerDV)); }
public ViewResult CustomerEdit(int customerId) { Customer customer = FakeDB.GetCustomers().First(c => c.Id == customerId); CustomerDataView customerDV = new CustomerDataView() { Sexes = FakeDB.GetSelectListItemSex(), Customer = customer, SexId = customer.Sex.Id }; return(View(customerDV)); }
public ActionResult AddCustomer(CustomerDataView customerDV) { if (!ModelState.IsValid) { return(View("CustomerAdd", new CustomerDataView() { Sexes = FakeDB.GetSelectListItemSex(), Customer = customerDV.Customer, SexId = customerDV.SexId })); } FakeDB.InsertCustomer(customerDV.Customer); return(Redirect("/Customers")); }