public ActionResult Join(int id) { ApplicationUser user = userRepository.GetUser(User.Identity.GetUserId()); Game game = gameRepository.GetGame(id); //sprawdzanie czy gracz nie ma juz zaczętych maksymalnej liczby gier if (userRepository.HaveMaxGames(user)) { return(RedirectToAction("GameList", new { id = true })); } //jeżeli gra ma hasło wyswietl strone do wprowadzania hasła if (game.HavePassword()) { JoinViewModel viewModel = new JoinViewModel { Id = id, Name = game.Name }; return(View(viewModel)); } if (game.Players.Contains(user) || game.IsBegan) { return(RedirectToAction("GameList")); } gameRepository.AddUserToGame(user, game); return(RedirectToAction("GameList")); }