public bool Bid(BidsModel bidsModel, string ID) { //TODO var bid = bidsRepo.GetMaxBidOfAuction(bidsModel.AuctionId); var auction = auctionRepo.GetSingleElementByID(ID); if (!auctionRepo.CheckIfAuctionEnded(ID)) { if (bid == null) { auction.EndingPrice = bidsModel.Value; bidsRepo.Insert(bidsModel); bidsRepo.Save(); return(true); } if (!auctionRepo.CheckIfEndingPriceIsOk(bidsModel)) { return(true); } bidsRepo.Insert(bidsModel); bidsRepo.Save(); return(true); } return(false); }
public AuctionDetailsViewModel LoadAuction(string ID, string currency, ICurrencyExchangeRepository currencyExchangeRepository) { try { //TODO auctionRepo.CheckIfAuctionEnded(ID); auctionRepo.CheckIfEndingPriceIsOk(bidsRepo.GetMaxBidOfAuction(ID)); var auction = auctionRepo.GetSingleElementByID(ID); var startPrice = currencyExchangeRepository.GetValueInAnotherCurrency(auction.StartPrice, auction.Currency, currency); var endingPrice = currencyExchangeRepository.GetValueInAnotherCurrency(auction.EndingPrice, auction.Currency, currency); var bids = bidsRepo.GetBidsByAuctionID(ID); var bidsVM = new AuctionBidsViewModel(bids, currency, auction.Currency, currencyExchangeRepository); if (endingPrice != null && startPrice != null) { auction.EndingPrice = (decimal)endingPrice; auction.StartPrice = (decimal)startPrice; auction.Currency = currency; } var img = imageRepo.GetImagesByAuctionID(ID).ToList(); return(new AuctionDetailsViewModel(auction, bidsVM, img)); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return(null); } }