Exemplo n.º 1
0
 /// <summary>
 /// Returns all states in country with given ID.
 /// </summary>
 /// <param name="countryId">Country identifier</param>
 /// <returns>Collection of all states in county.</returns>
 public IEnumerable <StateInfo> GetCountryStates(int countryId)
 {
     return(RepositoryCacheHelper.CacheObjects(() =>
     {
         return stateInfoProvider.Get().WhereEquals("CountryID", countryId);
     }, $"{nameof(KenticoCountryRepository)}|{nameof(GetCountryStates)}|{countryId}"));
 }
Exemplo n.º 2
0
        public JsonResult CountryStates(int countryId)
        {
            // Gets the display names of the country's states
            var responseModel = stateInfo.Get().WhereEquals("CountryID", countryId)
                                .Select(s => new
            {
                id   = s.StateID,
                name = HTMLHelper.HTMLEncode(s.StateDisplayName)
            });

            // Returns serialized display names of the states
            return(Json(responseModel));
        }
        public OrderAddressViewModel(OrderAddressInfo address, ICountryInfoProvider countryInfoProvider, IStateInfoProvider stateInfoProvider)
        {
            if (address == null)
            {
                return;
            }

            if (countryInfoProvider == null)
            {
                throw new ArgumentNullException(nameof(countryInfoProvider));
            }
            if (stateInfoProvider == null)
            {
                throw new ArgumentNullException(nameof(stateInfoProvider));
            }

            AddressLine1      = address.AddressLine1;
            AddressLine2      = address.AddressLine2;
            AddressCity       = address.AddressCity;
            AddressPostalCode = address.AddressZip;
            AddressState      = stateInfoProvider.Get(address.AddressStateID)?.StateDisplayName ?? String.Empty;
            AddressCountry    = countryInfoProvider.Get(address.AddressCountryID)?.CountryDisplayName ?? String.Empty;
        }