예제 #1
0
        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());
        }
예제 #2
0
        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);
        }
예제 #3
0
 private bool IsLowerThanFloor(SiteBid currentSiteBid, double currentBidderPrice)
 {
     return(currentBidderPrice < _sites[currentSiteBid.SiteName].Floor);
 }