예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 public bool CreateComment(string rate, string desc, string ID)
 {
     try
     {
         var auction = auctionRepo.GetSingleElementByID(ID);
         var comment = new CommentsModel
         {
             Rate        = int.Parse(rate),
             Description = desc,
             Id          = Guid.NewGuid().ToString(),
             AuctionId   = auction.Id,
             BuyerId     = auction.WinnerId,
             SellerId    = auction.CategoryId
         };
         commentsRepo.Insert(comment);
         commentsRepo.Save();
         return(true);
     }
     catch (Exception ex)
     {
         ErrorSignal.FromCurrentContext().Raise(ex);
         return(false);
     }
 }
예제 #4
0
        public static string GetAuctionTitle(string ID)
        {
            var repo = new AuctionsRepository();

            return(repo.GetSingleElementByID(ID).Title);
        }