public static IDictionary <string, int> SetAddressBidCountDict(this BidVM bidVM, DiscountScheme discountScheme)
 {
     if (bidVM.DiscountSchemeId != discountScheme.DiscountSchemeId)
     {
         throw new InvalidOperationException("DiscountScheme Ids do not match");
     }
     bidVM.AddressBidCountDict = _SetAddressBidCountDict(discountScheme);
     return(bidVM.AddressBidCountDict);
 }
 public ActionResult Bid(BidVM peanutbutter)
 {
     if (ModelState.IsValid)
     {
         //               bid.Bid.ItemId = id;
         _db.Bids.Add(peanutbutter.Bid);
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
        public ActionResult Bid(int id)
        {
            var item  = _db.Items.Where(i => i.Id == id).Include(i => i.Bids).FirstOrDefault();
            var bidVM = new BidVM
            {
                Bids = item.Bids.ToList(),
                Bid  = new Bid
                {
                    ItemId = item.Id
                }
            };


            return(View(bidVM));
        }
Example #4
0
        public ActionResult PostBid(AuctionItemPage currentPage, BidStuff BidThing)
        {
            string idStr = currentPage.PageLink.ToString();
            int    id    = Convert.ToInt32(idStr);

            BidVM bid = new BidVM();

            bid.ItemId    = id;
            bid.BidAmount = BidThing.BidAmount;
            bid.NewBidder = BidThing.NewBidder;

            string message = SQLQuery.AddBidToDB(bid);

            return(RedirectToAction("Index"));
        }
Example #5
0
        public ActionResult Bid(int id, BidVM bidVM)
        {
            // get previous max bid
            var maxBid = _db.Bids.Where(b => b.ItemId == id).Max(b => b.BidAmount);

            if (bidVM.Bid.BidAmount <= maxBid)
            {
                ModelState.AddModelError("Bid.BidAmount", "New bid must be greater than previous maximum bid");
            }
            // check for validation errors
            if (ModelState.IsValid)
            {
                bidVM.Bid.ItemId = id;
                _db.Bids.Add(bidVM.Bid);
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            // need to repopulate previous bids
            bidVM.Bids = _db.Bids.Where(b => b.ItemId == id).ToList();
            return(View(bidVM));
        }