private IList <Bid> ProcessBids(SiteBid currentSiteBid, IList <Bid> bids) { var largestBids = new Dictionary <string, Bid>(); foreach (var bid in bids) { if (IsInValidBid(currentSiteBid, bid)) { continue; } var bidderAdjustment = _bidders[bid.BidderName]; var currentBidderPrice = bid.Price + (bid.Price * bidderAdjustment); if (IsLowerThanFloor(currentSiteBid, currentBidderPrice)) { continue; } if (largestBids.ContainsKey(bid.Unit) && IsLargerThanLargestBid(currentBidderPrice, bidderAdjustment, largestBids[bid.Unit])) { largestBids[bid.Unit] = bid; } if (!largestBids.ContainsKey(bid.Unit)) { largestBids.Add(bid.Unit, bid); } } return(largestBids.Select(x => x.Value).ToList()); }
private bool IsInValidBid(SiteBid currentSiteBid, Bid bid) { var site = _sites[currentSiteBid.SiteName]; if (!site.ContainsBidderName(bid.BidderName) || !_bidders.ContainsKey(bid.BidderName)) { return(true); } if (!currentSiteBid.ContainsUnit(bid.Unit)) { return(true); } return(false); }
private bool IsLowerThanFloor(SiteBid currentSiteBid, double currentBidderPrice) { return(currentBidderPrice < _sites[currentSiteBid.SiteName].Floor); }