public CompletedAuction CalculateWinners(Auction auction) { List <AuctionBid> bids = auction.Bids.ToList(); log.LogTrace("Finding winners for {0} from bids submitted: ({1})", auction.DetailDescription, string.Join("', ", auction.Bids)); List <AuctionBid> winners = new List <AuctionBid>(); for (int i = 0; i < auction.Quantity; i++) { if (bids.Any()) { // Grab the first winner. AuctionBid winner = RemoveWinner(bids); winners.Add(winner); } } List <WinningBid> winningBids = CalculatePrices(winners, bids); log.LogInformation("{0} found {1} winners: {2}", auction.DetailDescription, winners.Count, string.Join(", ", winners)); return(new CompletedAuction(auction, winningBids)); }
public CompletedAuction(Auction auction, List <WinningBid> winningBids) { Auction = auction; WinningBids = winningBids; }