コード例 #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
ファイル: AuctionDetailsModel.cs プロジェクト: wkmalek/AHMVP
        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
ファイル: UserCommentsModel.cs プロジェクト: wkmalek/AHMVP
 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);
        }