public ActionResult SelectAddress()
        {
            var currentUser = _authenticationService.GetAuthenticatedUser();

            if (currentUser == null)
                throw new OrchardSecurityException(T("Login required"));

            var customer = currentUser.ContentItem.As<CustomerPart>();

            if (customer == null)
            {
                //throw new Exception("Logged on user is NOT a customer.");
                return RedirectToAction("SignupOrLogin");
            }

            var invoiceAddress = _customerService.GetAddress(customer.Id, "InvoiceAddress");
            var shippingAddress = _customerService.GetAddress(customer.Id, "ShippingAddress");

            var addressesViewModel = new AddressesViewModel
            {
                InvoiceAddress = MapAddress(invoiceAddress, customer),
                ShippingAddress = MapAddress(shippingAddress, customer)
            };

            var shape = _services.New.Checkout_SelectAddress(Addresses: addressesViewModel, ContinueShoppingUrl: _webshopSettings.GetContinueShoppingUrl());
            if (string.IsNullOrWhiteSpace(addressesViewModel.InvoiceAddress.Name))
                addressesViewModel.InvoiceAddress.Name = string.Format("{0} {1} {2}", customer.Title, customer.FirstName, customer.LastName);
            return new ShapeResult(this, shape);
        }
        public ActionResult SelectAddress(AddressesViewModel addresses)
        {
            var currentUser = _authenticationService.GetAuthenticatedUser();

            if (currentUser == null)
                throw new OrchardSecurityException(T("Login required"));

            addresses.InvoiceAddress.CountryCodes = CountryCode.SelectList;
            addresses.ShippingAddress.CountryCodes = CountryCode.SelectList;

            if (!ModelState.IsValid)
            {
                return new ShapeResult(this, _services.New.Checkout_SelectAddress(Addresses: addresses, ContinueShoppingUrl: _webshopSettings.GetContinueShoppingUrl()));
            }

            var customer = currentUser.ContentItem.As<CustomerPart>();

            if (addresses.InvoiceAddress.IsValidAddress())
                MapAddress(addresses.InvoiceAddress, "InvoiceAddress", customer);
            if (addresses.ShippingAddress.IsValidAddress())
                MapAddress(addresses.ShippingAddress, "ShippingAddress", customer);

            // subscribe to mailing list if they asked for it
            if (_webshopSettings.Settings.UseMailChimp && customer.SubscribeToMailingList)
            {
                _messageManager.Send(new[] { currentUser.Email }, "SUBSCRIBE", "email", new Dictionary<string, string>
                    {
                        {"LastName", customer.LastName},
                        {"FirstName", customer.FirstName},
                        {"Address", addresses.InvoiceAddress.Address},
                        {"City", addresses.InvoiceAddress.City},
                        {"State", addresses.InvoiceAddress.State},
                        {"CountryCode", addresses.InvoiceAddress.CountryCode},
                        {"Postcode", addresses.InvoiceAddress.Postcode},
                        {"ReceivePost", customer.ReceivePost.ToString()} ,
                        {"MailChimpApiKey", _webshopSettings.Settings.MailChimpApiKey},
                        {"MailChimpListName", _webshopSettings.Settings.MailChimpListName},
                        {"MailChimpGroupName", _webshopSettings.Settings.MailChimpGroupName},
                        {"MailChimpGroupValue", _webshopSettings.Settings.MailChimpGroupValue}
                    });
            }

            return RedirectToAction("Summary");
        }
        public ActionResult SelectAddress(AddressesViewModel addresses)
        {
            var currentUser = _authenticationService.GetAuthenticatedUser();

            if (currentUser == null)
                throw new OrchardSecurityException(T("Login required"));

            if (!addresses.InvoiceAddress.IsValidAddress())
                ModelState.AddModelError("InvalidInvoiceAddress", "Please correct the Invoice Address and try again.");

            if(addresses.ShippingAddressSupplied && !addresses.ShippingAddress.IsValidAddress())
                ModelState.AddModelError("InvalidShippingAddress", "Please correct the Shipping Address and try again.");
            
            if (!ModelState.IsValid)
            {
                addresses.InvoiceAddress.CountryCodes = CountryCode.SelectList;
                addresses.ShippingAddress.CountryCodes = CountryCode.SelectList;

                return new ShapeResult(this, _services.New.Checkout_SelectAddress(Addresses: addresses, ContinueShoppingUrl: _webshopSettings.GetContinueShoppingUrl()));
            }

            var customer = currentUser.ContentItem.As<CustomerPart>();

            MapAddress(addresses.InvoiceAddress, "InvoiceAddress", customer);

            if(addresses.ShippingAddressSupplied)
                MapAddress(addresses.ShippingAddress, "ShippingAddress", customer);

            return RedirectToAction("Summary");
        }