public AuctionStatus AuctionStatus(Guid auctionId) { var status = _session .CreateSQLQuery(String.Format("select Id, CurrentPrice, BidderMemberId as WinningBidderId, AuctionEnds from Auctions Where Id = '{0}'", auctionId)) .SetResultTransformer(Transformers.AliasToBean <AuctionStatus>()) .UniqueResult <AuctionStatus>(); status.TimeRemaining = TimeRemaining(status.AuctionEnds); status.NumberOfBids = _bidHistory.NoOfBidsFor(auctionId); return(status); }
public AuctionStatus ConvertToStatus(AuctionSnapshot snapshot) { var status = new AuctionStatus(); status.AuctionEnds = snapshot.EndsAt; status.Id = snapshot.Id; status.TimeRemaining = TimeRemaining(snapshot.EndsAt); if (snapshot.WinningBid != null) { status.NumberOfBids = _bidHistory.NoOfBidsFor(snapshot.Id); status.WinningBidderId = snapshot.WinningBid.BiddersId; status.CurrentPrice = snapshot.WinningBid.CurrentPrice; } return(status); }
public AuctionStatus AuctionStatus(Guid auctionId) { var auction = _auctions.FindBy(auctionId); var status = new AuctionStatus(); status.AuctionEnds = auction.EndsAt; status.Id = auction.Id; if (auction.HasBeenBidOn()) { status.CurrentPrice = auction.WinningBid.CurrentAuctionPrice.Amount.Value; status.WinningBidderId = auction.WinningBid.Bidder; } status.TimeRemaining = TimeRemaining(auction.EndsAt); status.NumberOfBids = _bidHistory.NoOfBidsFor(auctionId); return(status); }