public ActionResult EditCustomer(Guid id) { var repository = new CustomerRepository(); var customer = repository.GetCustomer(id); var model = CustomerModelFromCustomer(customer); return View(model); }
public ActionResult EditCustomer(CustomerModel customerModel) { var repository = new CustomerRepository(); var customer = repository.GetCustomer(customerModel.CustomerId); CustomerFromCustomerModel(customerModel, customer); foreach (var addressModel in customerModel.AddressList) { var address = customer.Addresses.FirstOrDefault(a => a.AddressId == addressModel.AddressId); AddressFromAddressModel(address,addressModel); } repository.EditCustomer(customer); return RedirectToAction("Customers"); }