/// <summary> /// Registers the bid. /// </summary> /// <param name="person">The person.</param> /// <param name="bid">The bid.</param> /// <param name="auction">The auction.</param> /// <exception cref="System.Exception">INVALID BID!</exception> public void RegisterBid(Person person, Bid bid, Auction auction) { IPersonBidderTable personBidderTable = this.tablesProvider.GetPersonBidderTable(); IBidTable bidTable = this.tablesProvider.GetBidTable(); try { PersonBidder personBidder = personBidderTable.FetchPersonBidderByIdPerson(person.IdPerson); bid.PersonBidder = personBidder ?? throw new Exception("no person bidder!"); personBidder.Person = person; Bid highest_bid = this.GetHighestBid(auction); if (highest_bid != null) { highest_bid.PersonBidder = personBidderTable.FetchPersonByIdBid(highest_bid.IdBid); highest_bid.Currency = auction.Currency; highest_bid.Auction = auction; } bool isOkToPostBid = CanBidBePostedToActionCheck.DoCheck(personBidder, bid, auction, highest_bid); if (!isOkToPostBid) { throw new Exception("INVALID BID!"); } bidTable.InsertBid(personBidder.IdBidder, auction.IdAuction, auction.Currency.IdCurrency, bid); Log.Info("bid registered!"); } catch (Exception e) { throw e; } }
/// <summary> /// Prevents a default instance of the <see cref="DomainDataStorage"/> class from being created. /// </summary> private DomainDataStorage() { string connectionString = ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString; this.databaseConneection = new MySqlConnection(connectionString); this.auctionTable = this.databaseConneection.As <IAuctionTable>(); this.bidTable = this.databaseConneection.As <IBidTable>(); this.categoryTable = this.databaseConneection.As <ICategoryTable>(); this.currencyTable = this.databaseConneection.As <ICurrencyTable>(); this.personBidderTable = this.databaseConneection.As <IPersonBidderTable>(); this.personMarkTable = this.databaseConneection.As <IPersonMarkTable>(); this.personOfferorTable = this.databaseConneection.As <IPersonOfferorTable>(); this.personTable = this.databaseConneection.As <IPersonTable>(); this.productTable = this.databaseConneection.As <IProductTable>(); }
public PersonBidderTable(IBidTable bidTable) { this.bidTable = bidTable; }
/// <summary> /// Gets the highest bid. /// </summary> /// <param name="auction">The auction.</param> /// <returns> /// the highest bid if exists else it throws /// </returns> private Bid GetHighestBid(Auction auction) { IBidTable bidTable = this.tablesProvider.GetBidTable(); return(bidTable.FetchAuctionHighestBid(auction)); }