public List <AzureLocation> GetLocations(int day, string subscriptionId) { // Clean cache of items older than 12 hours _cachedLocations.RemoveAll(c => c.CacheDate <= DateTime.Now.AddHours(-12)); // Check cache for items var cacheItem = _cachedLocations.FirstOrDefault(c => c.SubscriptionId == subscriptionId); if (cacheItem == null) { // Add V12 locations for Subscription to Cache var allLocations = GetLocations(1); cacheItem = new CachedLocations() { SubscriptionId = subscriptionId, CacheDate = DateTime.Now, Locations = FilterLocationsToV12Capable(allLocations, subscriptionId) }; _cachedLocations.Add(cacheItem); } // Filter locations for the Day var availableLocationsForDay = GetLocations(day); return(cacheItem.Locations.Where(l => availableLocationsForDay.Any(a => a.Equals(l.Name))).ToList()); }
public List<AzureLocation> GetLocations(int day, string subscriptionId) { // Clean cache of items older than 12 hours _cachedLocations.RemoveAll(c => c.CacheDate <= DateTime.Now.AddHours(-12)); // Check cache for items var cacheItem = _cachedLocations.FirstOrDefault(c => c.SubscriptionId == subscriptionId); if (cacheItem == null) { // Add V12 locations for Subscription to Cache var allLocations = GetLocations(1); cacheItem = new CachedLocations() { SubscriptionId = subscriptionId, CacheDate = DateTime.Now, Locations = FilterLocationsToV12Capable(allLocations, subscriptionId) }; _cachedLocations.Add(cacheItem); } // Filter locations for the Day var availableLocationsForDay = GetLocations(day); return cacheItem.Locations.Where(l => availableLocationsForDay.Any(a => a.Equals(l.Name))).ToList(); }