Example #1
0
        protected override DriverResult Editor(
            AddressOrderPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            if (!Authorized(part))
            {
                return(null);
            }

            var updatedModel = new OrderAddressEditorViewModel();

            if (updater.TryUpdateModel(updatedModel, Prefix, null, null))
            {
                // shipping
                part.ShippingCountryId    = updatedModel.ShippingAddressVM.CountryId;
                part.ShippingCountryName  = updatedModel.ShippingAddressVM.Country;
                part.ShippingCityId       = updatedModel.ShippingAddressVM.CityId;
                part.ShippingCityName     = updatedModel.ShippingAddressVM.City;
                part.ShippingProvinceId   = updatedModel.ShippingAddressVM.ProvinceId;
                part.ShippingProvinceName = updatedModel.ShippingAddressVM.Province;
                // billing
                part.BillingCountryId    = updatedModel.BillingAddressVM.CountryId;
                part.BillingCountryName  = updatedModel.BillingAddressVM.Country;
                part.BillingCityId       = updatedModel.BillingAddressVM.CityId;
                part.BillingCityName     = updatedModel.BillingAddressVM.City;
                part.BillingProvinceId   = updatedModel.BillingAddressVM.ProvinceId;
                part.BillingProvinceName = updatedModel.BillingAddressVM.Province;
            }

            return(Editor(part, shapeHelper));
        }
Example #2
0
        protected override DriverResult Editor(
            AddressOrderPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            if (!Authorized(part))
            {
                return(null);
            }

            var updatedModel = new OrderAddressEditorViewModel();

            if (!part.ShippingAddressIsOptional)
            {
                updater.TryUpdateModel(updatedModel, Prefix, null, null);

                // shipping
                // before assigning the viewmodel value to the address I check
                // that the city and province values ​​are correct
                ValidateVM(updatedModel.ShippingAddressVM);

                part.ShippingCountryId    = updatedModel.ShippingAddressVM.CountryId;
                part.ShippingCountryName  = updatedModel.ShippingAddressVM.Country;
                part.ShippingCityId       = updatedModel.ShippingAddressVM.CityId;
                part.ShippingCityName     = updatedModel.ShippingAddressVM.City;
                part.ShippingProvinceId   = updatedModel.ShippingAddressVM.ProvinceId;
                part.ShippingProvinceName = updatedModel.ShippingAddressVM.Province;
            }
            else
            {
                updater.TryUpdateModel(updatedModel, Prefix, null, new[] { "ShippingAddressVM" });
            }
            _justUpdated = true;

            // billing
            // before assigning the viewmodel value to the address I check
            // that the city and province values ​​are correct
            ValidateVM(updatedModel.BillingAddressVM);

            part.BillingCountryId    = updatedModel.BillingAddressVM.CountryId;
            part.BillingCountryName  = updatedModel.BillingAddressVM.Country;
            part.BillingCityId       = updatedModel.BillingAddressVM.CityId;
            part.BillingCityName     = updatedModel.BillingAddressVM.City;
            part.BillingProvinceId   = updatedModel.BillingAddressVM.ProvinceId;
            part.BillingProvinceName = updatedModel.BillingAddressVM.Province;

            return(Editor(part, shapeHelper));
        }