Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,GameName,AmountPaid")] BuyGame buyGame)
        {
            if (id != buyGame.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(buyGame);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BuyGameExists(buyGame.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(buyGame));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,GameName,AmountPaid")] BuyGame buyGame)
        {
            if (ModelState.IsValid)
            {
                _context.Add(buyGame);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(buyGame));
        }
        public IActionResult BuyGame(int id, BuyGame gameITModel)
        {
            GameITModel postReply = _context.GameITModel.Find(id);

            if (postReply == null)
            {
                return(NotFound());
            }
            if (postReply != null)
            {
                TempData["Message"] = string.Format("Updated successfully");

                _context.BuyGame.Add(gameITModel);
                _context.SaveChanges();
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #4
0
        public ActionResult Save(BuyGame buygame)
        {
            buygame.DateAdded = DateTime.Now;

            _context.BuyGames.Add(buygame);

            var game = _context.Games.SingleOrDefault(x => x.Id == buygame.GameId);

            if (game.Stock != 0)
            {
                game.Stock = game.Stock - buygame.Stock;
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "Customers"));
        }
Example #5
0
        public ActionResult MakeBuy(BuyGame buygame)
        {
            if (!ModelState.IsValid)
            {
                return(View("Manager", buygame));
            }

            var viewModel = new BuyGame2ViewModel
            {
                BuyGame         = new BuyGame(),
                Customer        = _context.Customers.Single(c => c.Id == buygame.CustomerId),
                Game            = _context.Games.Single(c => c.Id == buygame.GameId),
                Genres          = _context.Genres.ToList(),
                Consoles        = _context.Consoles.ToList(),
                MembershipTypes = _context.MembershipTypes.ToList()
            };

            return(View(viewModel));
        }