Example #1
0
        // GET: Bids/Create
        public ActionResult BidOnItem(int id)
        {
            var vm = new BidOnItemVM
            {
                Item = _db.Items.Find(id)
            };

            return(View(vm));
        }
Example #2
0
        public ActionResult BidOnItem(int id, Bid bid)
        {
            var original = _db.Items.Find(id);

            if (ModelState.IsValid)
            {
                original.Bids.Add(bid);
                original.NumberOfBids = (from n in _db.Bids where n.Item.Id == id select n).Count() + 1;
                _db.SaveChanges();
                return(RedirectToAction("Index", "Items"));
            }
            var vm = new BidOnItemVM
            {
                Item = original
            };

            return(View(vm));
        }