public ActionResult BuyGame(GameToUser new_relation)
        {
            var user = dbContext.Users.Find(new_relation.UserId);
            var game = dbContext.Games.Find(new_relation.GameId);

            user.All_Games.Add(game);
            user.Balance       = user.Balance - game.Price;
            user.NumberOfGames = user.NumberOfGames + 1;

            dbContext.SaveChanges();

            return(RedirectToAction("ShowAllGames"));
        }
        public ActionResult BuyGame(int id)
        {
            var         user      = UserManager.FindById(User.Identity.GetUserId());
            List <Game> all_games = dbContext.Games.ToList();
            Game        new_game  = new Game();

            foreach (Game g in all_games)
            {
                if (g.Id == id)
                {
                    new_game = g;
                    break;
                }
            }

            List <Game> games_user = user.All_Games.ToList();

            foreach (Game g in games_user)
            {
                if (g.Id == id)
                {
                    return(View("GameBuyed"));
                }
            }

            if (user.Balance >= new_game.Price)
            {
                GameToUser new_relation = new GameToUser();
                new_relation.UserName = user.Name + " " + user.Surname;
                new_relation.GameName = new_game.Name;
                new_relation.GameId   = new_game.Id;
                new_relation.UserId   = user.Id;

                return(View(new_relation));
            }
            else
            {
                return(View("NotAllowed"));
            }
        }