public async Task <ActionResult <GameReadDto> > CreateGame(GameCreateDto gameCreateDto) { var user = await _userManager.FindByEmailAsync(HttpContext.User.Identity.Name); var game = _mapper.Map <Game>(gameCreateDto); game.Identity = user; _repository.CreateGame(game); _repository.saveChanges(); var gameReadDto = _mapper.Map <GameReadDto>(game); return(CreatedAtRoute(nameof(GetGameById), new { Id = gameReadDto.GameId }, gameReadDto)); }
/// <summary> /// Start a new game or reset a game. /// </summary> /// <param name="PlayerName"></param> /// <returns></returns> public async Task <Game> StartNewGame(string PlayerName) { var newGame = await _gameRepo.CreateGame(PlayerName); return(newGame); }