/// <summary> /// Gets the state list. /// </summary> /// <param name="languageCountryCode">The language country code to search on.</param> /// <returns>The state list.</returns> public virtual Data.Extended.StateList[] GetLongNameList(string languageCountryCode) { // Create the new cache control container. Nequeo.Data.Control.ICacheControl selectCache = Select; selectCache.CacheItems = true; selectCache.CachedItemName = "StateListLong" + languageCountryCode.ToString(); selectCache.CacheTimeout = 200; Data.Extended.StateList[] list = null; // Is the item to be cached. if (selectCache.CacheItems) { // Get the item from the cache. object item = selectCache.GetItemFromCache(selectCache.CachedItemName); if (item != null) { if (item is Data.Extended.StateList[]) { list = item as Data.Extended.StateList[]; } } } // If the item has not been cached // then get the items from the database. if (list == null) { // Get the langauge details. Data.Language language = DataContext.Languages.First(l => l.LanguageCountryCode == languageCountryCode); Data.Country country = DataContext.Countries.First(c => c.CountryName == language.CountryName); long countryID = country.CountryID; list = Select. SelectIQueryableItems(s => (s.StateVisible == true) && (s.CountryID == countryID)). OrderBy(s => s.GroupOrder). Select(s => new { StateID = s.StateID, StateName = s.StateLongName, StateCodeID = s.StateCodeID, CountryID = s.CountryID }).ToTypeArray <Data.Extended.StateList>(); } // Cache the item. if (selectCache.CacheItems) { selectCache.AddItemToCache(selectCache.CachedItemName, selectCache.CacheTimeout, list); } return(list); }
/// <summary> /// Gets the state list. /// </summary> /// <param name="countryID">The country id to search on.</param> /// <returns>The state list.</returns> public virtual Data.Extended.StateList[] GetShortNameList(long countryID) { // Create the new cache control container. Nequeo.Data.Control.ICacheControl selectCache = Select; selectCache.CacheItems = true; selectCache.CachedItemName = "StateListShort" + countryID.ToString(); selectCache.CacheTimeout = 200; Data.Extended.StateList[] list = null; // Is the item to be cached. if (selectCache.CacheItems) { // Get the item from the cache. object item = selectCache.GetItemFromCache(selectCache.CachedItemName); if (item != null) { if (item is Data.Extended.StateList[]) { list = item as Data.Extended.StateList[]; } } } // If the item has not been cached // then get the items from the database. if (list == null) { list = Select. SelectIQueryableItems(s => (s.StateVisible == true) && (s.CountryID == countryID)). OrderBy(s => s.GroupOrder). Select(s => new { StateID = s.StateID, StateName = s.StateShortName, StateCodeID = s.StateCodeID, CountryID = s.CountryID }).ToTypeArray <Data.Extended.StateList>(); } // Cache the item. if (selectCache.CacheItems) { selectCache.AddItemToCache(selectCache.CachedItemName, selectCache.CacheTimeout, list); } return(list); }