public ActionResult Bid(CreateBidViewModel model)
        {
            if (model.BidAmount < model.MinimumBid)
                ModelState.AddModelError("BidAmount", "Your bid amount is not greater than or equal to the minimum");

            if (!ModelState.IsValid)
                return View(model);

            _repo.AddBid(model);

            return RedirectToAction("Index");
        }
Exemple #2
0
        public void AddBid(CreateBidViewModel model)
        {
            using (AuctionDbContext db = new AuctionDbContext())
            {
                Bid dbBid = new Bid
                {
                    AuctionItemId = model.AuctionItemId,
                    BidAmount = model.BidAmount,
                    Name = model.Name
                };

                db.Bids.Add(dbBid);
                db.SaveChanges();
            }
        }