Пример #1
0
        public async Task <IActionResult> AddToCart(Game game)
        {
            var gameToAdd   = _context.Game.SingleOrDefault(g => g.GameID == game.GameID);
            var cartToAddTo = CartLogic.GetCart(_context, HttpContext);

            cartToAddTo.AddToCart(gameToAdd);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("GameID,Image,Title,Genre,UnitPrice,Description,UnitsInStock")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(game));
        }