Exemple #1
0
        public ActionResult ViewAuctionDetails(AuctionViewModel model)
        {
            var bidRepo = new BidRepository();
            var aucRepo = new AuctionRepository();
            var userRepo = new UserRepository();
            var auction = aucRepo.GetAuctionById(model.Id);
            model.Bid = aucRepo.GetHighestBid(model.Id);
            var returnModel = auction.ConvertToViewModel();
            if (model.NextBid.Price > (auction.MinPrice + auction.Interval) && model.NextBid.Price > model.Bid.Price)
            {
                model.NextBid.Auction = auction;
                model.NextBid.Active = true;
                model.NextBid.Date = DateTime.Now;
                model.NextBid.User = userRepo.GetUserById(1);
                bidRepo.InsertBid(model.NextBid);

                auction.Bids.Add(model.NextBid);
                returnModel.Bid = model.NextBid;
                returnModel.ErrorMessage = "Bud på auktionen er godkendt!";
            }
            else
            {
                returnModel.Bid = model.Bid;
                returnModel.ErrorMessage = "Bud for lavt!";
            }

            return View(returnModel);
        }
Exemple #2
0
 public void AuctionTestInitialize()
 {
     Console.Out.Write("AuctionTestInitialize called...");
     _auctionRepository = new AuctionRepository();
     _artworkRepository = new ArtworkRepository();
     _bidRepository = new BidRepository();
     _auction = new Auction();
 }
Exemple #3
0
 public void BidTestInitialize()
 {
     Console.Out.Write("BidTestInitialize called...");
     _bidRepository = new BidRepository();
     _auctionRepository = new AuctionRepository();
     _userRepository = new UserRepository();
     _bid = new Bid();
 }