コード例 #1
0
        public ActionResult EditCustomer(Guid id)
        {
            var repository = new CustomerRepository();
            var customer = repository.GetCustomer(id);
            var model = CustomerModelFromCustomer(customer);

            return View(model);
        }
コード例 #2
0
        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");
        }