public IDictionary <StoreKey, Store> GetStores(CalculationStep step, ICalculationSettings calculationSettings) { var allCountries = _countryService.GetCountries(); var allowedCountries = allCountries.Where( x => calculationSettings.AreAllCountriesAllowed || calculationSettings.AllowedCountryCodes.Contains(x.CountryCode) || calculationSettings.AllowedRegionCodes.Contains(x.RegionCode)) .ToList(); step.PercentComplete = 5; List <Store> stores = new List <Store>(); for (int i = 0; i < allowedCountries.Count; i++) { var country = allowedCountries[i]; var bricklinkStores = GetBricklinkStores(country); stores.AddRange(bricklinkStores); step.PercentComplete = 5 + (85 * (i + 1) / allowedCountries.Count); } var toRemove = stores.Where( s => calculationSettings.BlacklistedStores.Any(b => b.StoreType == s.StoreType && b.Id == s.Id)) .ToList(); foreach (var store in toRemove) { stores.Remove(store); } step.PercentComplete = 95; var result = new Dictionary <StoreKey, Store>(); int storeKey = 1; foreach (var store in stores) { store.StoreKey = (StoreKey)storeKey; result.Add((StoreKey)storeKey, store); storeKey++; } return(result); }
public void Initialize(IReadOnlyCollection <WantedListItem> items, ICalculationSettings calculationSettings) { _calculationSettings = calculationSettings; var wantedItems = items.ToList(); for (int i = 0; i < wantedItems.Count; i++) { _items.Add((WantedItemKey)i, wantedItems[i]); } InitializeSteps(); Status = CalculatorStatus.NotStarted; }