Exemplo n.º 1
0
 public static AddressEditViewModel CreateVM(
     IAddressConfigurationService _addressConfigurationService,
     AddressRecordType addressRecordType,
     AddressEditViewModel viewModel)
 {
     if (viewModel == null)
     {
         viewModel = CreateVM(_addressConfigurationService);
     }
     else
     {
         viewModel.Countries = _addressConfigurationService
                               .CountryOptions();
         if (addressRecordType == AddressRecordType.ShippingAddress)
         {
             viewModel.ShippingCountries = _addressConfigurationService
                                           .CountryOptions(AddressRecordType.ShippingAddress, viewModel.CountryId);
         }
         if (addressRecordType == AddressRecordType.BillingAddress)
         {
             viewModel.BillingCountries = _addressConfigurationService
                                          .CountryOptions(AddressRecordType.BillingAddress, viewModel.CountryId);
         }
         if (viewModel.ProvinceId <= 0 && !string.IsNullOrWhiteSpace(viewModel.Province))
         {
             viewModel.ProvinceId = -1;
         }
         if (viewModel.CityId <= 0 && !string.IsNullOrWhiteSpace(viewModel.City))
         {
             viewModel.CityId = -1;
         }
     }
     viewModel.AddressType = addressRecordType;
     return(viewModel);
 }
Exemplo n.º 2
0
 private static Address AddressFromVM(AddressEditViewModel vm)
 {
     //FixUpdate(vm);
     return(new Address {
         Honorific = vm.Honorific,
         FirstName = vm.FirstName,
         LastName = vm.LastName,
         Company = vm.Company,
         Address1 = vm.Address1,
         Address2 = vm.Address2,
         PostalCode = vm.PostalCode,
         // advanced address stuff
         // The string values here are the DisplayText properties of
         // configured territories, or "custom" text entered by the user.
         Country = vm.Country,
         City = vm.City,
         Province = vm.Province
     });
 }