示例#1
0
        public async Task <IActionResult> CreateGame(CreateGameParameters parameters)
        {
            var gameId = Guid.NewGuid();

            var card = Card.CreateNew(
                Guid.NewGuid(),
                gameId);

            var newGame = Game.CreateNew(
                id: Guid.NewGuid(),
                name: parameters.Name,
                card: card,
                numberOfCards: parameters.NumberOfCards.GetValueOrDefault());

            GetGameResults result = null;

            await _gameRepository.CreateGameAsync(newGame);

            if (await _gameRepository.CompleteAsync() > 0)
            {
                result = newGame.MapToContract();
            }
            else
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
示例#2
0
        public async Task <ActionResult <GameViewModel> > Add([FromQuery] CreateGameParameters parameters, CancellationToken cancellationToken)
        {
            var result = await _gameManagementService.Add(new Core.Entties.Game.Game(Guid.NewGuid().ToString("N"), parameters.Name, parameters.Description, parameters.Category, parameters.ImageUrl, parameters.ReleaseDate), cancellationToken);

            return(Ok(GameViewModel.Create(result)));
        }