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)));
        }
Beispiel #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)));
        }
        ShippingEstimateViewModel BuildViewModel(ShippingEstimateDetails shippingEstimateDetails, bool showNoRates)
        {
            if (shippingEstimateDetails == null)
            {
                shippingEstimateDetails = new ShippingEstimateDetails(
                    country: null,
                    city: null,
                    state: null,
                    postalCode: null);
            }

            var countries = AddressSelectListBuilder.BuildCountrySelectList(shippingEstimateDetails.Country);
            var states    = AddressSelectListBuilder.BuildStateSelectList(countries.SelectedValue.ToString(), shippingEstimateDetails.State);

            return(new ShippingEstimateViewModel
            {
                Country = shippingEstimateDetails.Country,
                Countries = countries,
                City = shippingEstimateDetails.City,
                State = shippingEstimateDetails.State,
                States = states,
                PostalCode = shippingEstimateDetails.PostalCode,
                ShowNoRates = showNoRates,
                ShippingCalculationRequiresCityAndState = Shipping.GetActiveShippingCalculationID() != Shipping.ShippingCalculationEnum.UseRealTimeRates
            });
        }
        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))));
        }