예제 #1
0
        public BillingAddressViewModel(AddressInfo address, SelectList countries, CountryRepository countryRepository, SelectList addresses = null)
        {
            if (address != null)
            {
                if (countryRepository == null)
                {
                    throw new ArgumentNullException(nameof(countryRepository));
                }

                BillingAddressLine1      = address.AddressLine1;
                BillingAddressLine2      = address.AddressLine2;
                BillingAddressCity       = address.AddressCity;
                BillingAddressPostalCode = address.AddressZip;
                BillingAddressState      = countryRepository.GetState(address.AddressStateID)?.StateDisplayName ?? String.Empty;
                BillingAddressCountry    = countryRepository.GetCountry(address.AddressCountryID)?.CountryDisplayName ?? String.Empty;
                Countries = countries;
            }

            BillingAddressCountryStateSelector = new CountryStateViewModel
            {
                Countries = countries,
                CountryID = address?.AddressCountryID ?? 0,
                StateID   = address?.AddressStateID ?? 0
            };

            BillingAddressSelector = new AddressSelectorViewModel
            {
                Addresses = addresses,
                AddressID = address?.AddressID ?? 0
            };
        }
예제 #2
0
 public static CafeViewModel GetViewModel(Cafe cafe, CountryRepository countryRepository, IStringLocalizer <SharedResources> localizer, IPageAttachmentUrlRetriever attachmentUrlRetriever)
 {
     return(new CafeViewModel
     {
         PhotoPath = cafe.Fields.Photo == null ? null : attachmentUrlRetriever.Retrieve(cafe.Fields.Photo).RelativePath,
         Note = cafe.Fields.AdditionalNotes,
         Contact = ContactViewModel.GetViewModel(cafe, countryRepository, localizer)
     });
 }
예제 #3
0
        public static ContactViewModel GetViewModel(IContact contact, CountryRepository countryProvider, IStringLocalizer localizer)
        {
            var countryStateName = CountryStateName.Parse(contact.Country);
            var country          = countryProvider.GetCountry(countryStateName.CountryName);
            var state            = countryProvider.GetState(countryStateName.StateName);

            var model = new ContactViewModel(contact)
            {
                CountryCode = country.CountryTwoLetterCode,
                Country     = localizer[country.CountryDisplayName]
            };

            if (state != null)
            {
                model.StateCode = state.StateName;
                model.State     = localizer[state.StateDisplayName];
            }

            return(model);
        }