public async Task <ApiResponse <GameModel> > CreateGame() { if (User.Identity.IsAuthenticated) { return(BadRequest("User is already in a game.")); } var game = new Game( Guid.NewGuid().ToString().Substring(0, 6).ToUpper(), _nameGenerator.GetRandomName(), Team.Red); await _repository.AddGame(game); var player = game.Players.First(); await SignInAsPlayer(player, game.Code); return(Created(game.Code, new GameModel(game, player.Id))); }
public string GetRandomName() => _nameGenerator.GetRandomName();