Example #1
0
        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));
        }