Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<SimpleKeyValue<int?, string>> ListDictionaryItemsAsKeyValueByDictionaryCodename(Dictionaries.Codename DictionaryCodenameItem,int? SelectedKey = null, ICacheAssistance Cache = null)
- {
- if(Cache == null)
- {
- Cache = new MemoryCacheAssistance();
- }
- var Items = Cache.GetDataFromCache<List<SimpleKeyValue<int?, string>>>(DictionaryCodenameItem.DictionaryName);
- if (Items == null)
- {
- Items = ListDictionaries(Level: 1, DictionaryCode: DictionaryCodenameItem.DictionaryCode).Select(Item => new SimpleKeyValue<int?, string> { Key = Item.DictionaryID, Value = Item.Caption }).ToList();
- if (Items != null)
- {
- Cache.SetDataToCache(DictionaryCodenameItem.DictionaryName, Items, DateTime.Now.AddMinutes(AppSettings.CacheDurationInSecondsDefault));
- }
- }
- var ItemsCloned = Items.Clone();
- if (SelectedKey.HasValue)
- {
- var SelectedItem = ItemsCloned.Find(Item => Item.Key == SelectedKey);
- if (SelectedItem != null)
- {
- SelectedItem.IsSelected = true;
- }
- }
- return ItemsCloned;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement