public ActionResult Detail(int?addressId, string addressType, string returnUrl, bool makePrimary = false)
        {
            var customer = HttpContext.GetCustomer();

            var safeReturnUrl = Url.MakeSafeReturnUrl(returnUrl, Url.Action(ActionNames.Index));

            var address = ControllerHelper.GetCustomerAddress(addressId, customer);

            var addressTypeValue = GetAddressType(addressType);

            var countries = SelectListBuilder.BuildCountrySelectList(address.Country);
            var states    = SelectListBuilder.BuildStateSelectList(countries.SelectedValue.ToString(), address.State);

            return(View(new AddressDetailViewModel(
                            address: address,
                            residenceTypeOptions: SelectListBuilder.BuildResidenceTypeSelectList(address.ResidenceType),
                            stateOptions: states,
                            countryOptions: countries,
                            showCompanyField: AddressSettings.ShowCompanyField,
                            showNickName: AddressSettings.ShowNickName,
                            showSuite: AddressSettings.ShowSuite,
                            showResidenceTypeField: ShowResidenceTypeField(addressTypeValue),
                            returnUrl: safeReturnUrl,
                            header: AddressHeaderProvider.GetHeaderText(address.Id, addressTypeValue),
                            showPostalCodeLookup: PostalCodeLookupProvider.IsEnabled(countries.SelectedValue.ToString()),
                            addressType: addressTypeValue,
                            makePrimary: makePrimary,
                            enablePhoneInputMask: AddressSettings.UsePhoneNumberMask)));
        }
Exemple #2
0
        public ActionResult Detail(int?addressId, string addressType, string returnUrl, bool makePrimary = false)
        {
            var customer = HttpContext.GetCustomer();

            var safeReturnUrl = Url.MakeSafeReturnUrl(returnUrl, Url.Action(ActionNames.Index));

            ViewBag.MetaTitle = "Your Address Book";

            var address = ControllerHelper.GetCustomerAddress(addressId, customer);

            AddressTypes addressTypeValue;

            if (!Enum.TryParse(addressType, out addressTypeValue))
            {
                addressTypeValue = AddressTypes.Unknown;
            }

            return(View(new AddressDetailViewModel(
                            address: address,
                            residenceTypeOptions: SelectListBuilder.BuildResidenceTypeSelectList(address.ResidenceType),
                            stateOptions: SelectListBuilder.BuildStateSelectList(address.Country, address.State),
                            countryOptions: SelectListBuilder.BuildCountrySelectList(address.Country),
                            showCompanyField: ShowCompanyField,
                            showNickName: ShowNickName,
                            showResidenceTypeField: addressTypeValue == AddressTypes.Shipping || !AllowDifferentShipTo,
                            returnUrl: safeReturnUrl,
                            header: AddressHeaderProvider.GetHeaderText(address.Id, addressTypeValue),
                            showPostalCodeLookup: PostalCodeLookupProvider.IsEnabled(string.IsNullOrEmpty(address.Country)
                                        ? AppLogic.GetCountryNameFromTwoLetterISOCode("US")
                                        : address.Country),
                            addressType: addressTypeValue,
                            makePrimary: makePrimary)));
        }
        public ActionResult Index()
        {
            var customer = HttpContext.GetCustomer();

            var shippingAddress = AddressViewModelConverter.ConvertToAddressViewModel(
                customer.PrimaryShippingAddress,
                customer);

            return(View(new AddressDetailViewModel(
                            address: shippingAddress,
                            residenceTypeOptions: AddressSelectListBuilder.BuildResidenceTypeSelectList(shippingAddress.ResidenceType.ToString()),
                            stateOptions: AddressSelectListBuilder.BuildStateSelectList(shippingAddress.Country, shippingAddress.State),
                            countryOptions: AddressSelectListBuilder.BuildCountrySelectList(shippingAddress.Country),
                            showCompanyField: ShowCompanyField,
                            showNickName: ShowNickName,
                            showResidenceTypeField: true,
                            showPostalCodeLookup: PostalCodeLookupProvider.IsEnabled(shippingAddress.Country),
                            returnUrl: string.Empty,
                            header: AddressHeaderProvider.GetHeaderText(shippingAddress.Id, AddressTypes.Shipping))));
        }