public ActionResult Info(CustomerInfoModel model, FormCollection form) { if (!_workContext.CurrentCustomer.IsRegistered()) return new HttpUnauthorizedResult(); var customer = _workContext.CurrentCustomer; try { if (ModelState.IsValid) { customer.FirstName = model.FirstName; customer.LastName = model.LastName; customer.PhoneNumber = model.PhoneNumber; customer.Address1 = model.Address1; customer.Address2 = model.Address2; customer.City = model.City; customer.ZipPostalCode = model.ZipPostalCode; _customerService.UpdateCustomer(customer); return RedirectToRoute("CustomerInfo"); } } catch (Exception exc) { ModelState.AddModelError("", exc.Message); } return View(model); }
protected void PrepareCustomerInfoModel(CustomerInfoModel model, Customer customer) { model.Id = customer.Id; model.FirstName = customer.FirstName; model.LastName = customer.LastName; model.Email = customer.Email; model.ZipPostalCode = customer.ZipPostalCode; model.PhoneNumber = customer.PhoneNumber; model.City = customer.City; model.Address1 = customer.Address1; model.Address2 = customer.Address2; }
public ActionResult Info() { if (!_workContext.CurrentCustomer.IsRegistered()) return new HttpUnauthorizedResult(); var customer = _workContext.CurrentCustomer; var model = new CustomerInfoModel(); PrepareCustomerInfoModel(model, customer); return View(model); }