private IList <Price> GetMergedPriceDefault(IList <CsvPrice> restPrices) { if (!restPrices.Any()) { return(new List <Price>()); } var criteria = new Domain.Pricing.Model.Search.PricesSearchCriteria { ProductIds = restPrices.Select(x => x.ProductId).ToArray(), Take = 1000 }; var result = new List <Price>(); var existPrices = _pricingSearchService.SearchPrices(criteria).Results; foreach (var price in restPrices) { var existPrice = existPrices.FirstOrDefault(x => x.Currency.EqualsInvariant(price.Currency) && x.ProductId.EqualsInvariant(price.ProductId)); if (existPrice != null) { price.MergeFrom(existPrice); } result.Add(price); } return(result); }
private IList <Price> GetMergedPriceByPriceList(IList <CsvPrice> pricesWithPriceListIds) { if (!pricesWithPriceListIds.Any()) { return(new List <Price>()); } var existPrices = new List <Price>(); var dictionary = pricesWithPriceListIds.GroupBy(x => x.PricelistId).ToDictionary(g => g.Key, g => g.ToArray()); foreach (var priceListId in dictionary.Keys) { var criteria = new Domain.Pricing.Model.Search.PricesSearchCriteria { PriceListId = priceListId, ProductIds = dictionary[priceListId].Select(x => x.ProductId).ToArray(), Take = 1000 }; existPrices.AddRange(_pricingSearchService.SearchPrices(criteria).Results); } var result = new List <Price>(); foreach (var price in pricesWithPriceListIds) { var existPrice = existPrices.FirstOrDefault(x => x.Currency.EqualsInvariant(price.Currency) && x.ProductId.EqualsInvariant(price.ProductId) && x.PricelistId.EqualsInvariant(price.PricelistId)); if (existPrice != null) { price.MergeFrom(existPrice); } result.Add(price); } return(result); }