Пример #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);
        }
Пример #2
0
 public ActionResult ViewAuctionDetails(int id)
 {
     var repo = new AuctionRepository();
     var model = repo.GetAuctionById(id).ConvertToViewModel();
     model.Bid = repo.GetHighestBid(id) ?? new Bid(){Price = model.MinPrice};
     return View(model);
 }