Example #1
0
        public async Task <IActionResult> PostGame([FromBody] PostGameRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(HandleAndReturnBadRequest(ModelState, _logger));
            }

            var game = _mapper.Map <Game>(request);
            await _gameRepository.InsertAsync(game);

            var rounds = await _roundRepository.GetNotAttachedRoundsByGameGuidAsync(game.InGameId);

            foreach (var round in rounds)
            {
                round.GameId = game.Id;
            }

            await _roundRepository.SaveChangesAsync();

            return(Ok());
        }