Exemplo n.º 1
0
        public ActionResult AddOwnedGame(int GameId, string UserId)
        {
            var model = new UserOwnedGame();

            model.GameId = GameId;
            model.UserId = UserId;

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult AddOwnedGame(UserOwnedGame model)
        {
            var search = db.UserOwnedGames.Find(model.GameId, model.UserId);

            if (search == null)
            {
                db.UserOwnedGames.Add(model);
            }
            var gameToUpdate = db.Games.Find(model.GameId);
            int solded       = gameToUpdate.getSold();

            gameToUpdate.setSold(solded + 1);

            db.Games.AddOrUpdate(gameToUpdate);

            db.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }