Example #1
0
        public static CustomerAddress AsWebModel(this CustomerAddressFormModel formModel)
        {
            var customerAddress = new CustomerAddress();

            customerAddress.Address1     = formModel.Address1;
            customerAddress.Address2     = formModel.Address2;
            customerAddress.City         = formModel.City;
            customerAddress.Company      = formModel.Company;
            customerAddress.Country      = formModel.Country;
            customerAddress.CountryCode  = "US";
            customerAddress.FirstName    = formModel.FirstName;
            customerAddress.Id           = formModel.Id;
            customerAddress.LastName     = formModel.LastName;
            customerAddress.Phone        = formModel.Phone;
            customerAddress.Province     = formModel.Province;
            customerAddress.ProvinceCode = formModel.ProvinceCode;
            customerAddress.Zip          = formModel.Zip;

            return(customerAddress);
        }
Example #2
0
        public async Task <ActionResult> EditAddress(CustomerAddressFormModel formModel, string id)
        {
            var form = GetForm(formModel.form_type);

            var customer        = this.Context.Customer;
            var customerAddress = customer.Addresses.FirstOrDefault(a => a.Id == id);

            if (customerAddress != null)
            {
                customer.Addresses.Remove(customerAddress);
                customer.Addresses.Add(formModel.AsWebModel());
            }
            else
            {
                customer.Addresses.Add(formModel.AsWebModel());
            }

            await this.CustomerService.UpdateCustomerAsync(customer);

            return(RedirectToAction("Addresses", "Account"));
        }