private void QuoteBestPrice(QuotationFulfillment quotationFulfillment) { FulfilledPriceQuotes.Where(x => x.Id == quotationFulfillment.Id).ToList().ForEach(x => { quotationFulfillment.Requester.Tell(BestPriceQuotationFrom(quotationFulfillment)); FulfilledPriceQuotes.Remove(x); }); }
private BestPriceQuotation BestPriceQuotationFrom(QuotationFulfillment quotationFulfillment) { var bestPrices = quotationFulfillment .PriceQuotes.GroupBy(x => x.ItemId) .Select(x => new { x.Key, BestPrice = x.OrderByDescending(t => t.DiscountPrice).First() }) .Select(x => x.BestPrice).ToList(); return(new BestPriceQuotation(quotationFulfillment.Id, bestPrices)); }