コード例 #1
0
        public async Task <ActionResult <GamePlayModel> > GetByIdAsync(int id, CancellationToken cancellationToken)
        {
            var userId   = (await GetUserAsync(cancellationToken: cancellationToken))?.Id;
            var gamePlay = await _gamePlayService.GetGamePlayByIdAsync(id, userId, cancellationToken : cancellationToken);

            var moves = await _moveService.GetMovesAsync(id, cancellationToken : cancellationToken);

            var cardFilter = new CardSearchFilter
            {
                Ids = moves.Select(x => x.CardId).ToArray(),
            };
            var playedCards = await _cardService.GetCardsAsync(cardFilter, cancellationToken : cancellationToken);

            gamePlay.Moves = moves.Select(x => new MoveModel
            {
                CardId = x.CardId,
                GameDeckCardCollectionId = x.GameDeckCardCollectionId,
                Column = x.Column,
                Row    = x.Row,
            }).ToList();

            gamePlay.PlayedCards = Array.AsReadOnly(playedCards.Results);

            return(gamePlay);
        }
コード例 #2
0
        public async Task <ActionResult <GamePlayModel> > GetByIdAsync(int id, CancellationToken cancellationToken)
        {
            var userId   = (await GetUserAsync(cancellationToken: cancellationToken))?.Id;
            var gamePlay = await _gamePlayService.GetGamePlayByIdAsync(id, userId, cancellationToken : cancellationToken);

            var moves = await _moveService.GetMovesAsync(id, cancellationToken : cancellationToken);

            var cardFilter = new CardSearchFilter
            {
                Ids = moves.Select(x => x.CardId).ToArray(),
            };
            var playedCards = await _cardService.GetCardsAsync(cardFilter, cancellationToken : cancellationToken);

            gamePlay.Moves = await _moveUserService.PopulateMoveUsersAsync(moves, playedCards.Results, gamePlay.Game.UserIds, cancellationToken : cancellationToken);

            gamePlay.PlayedCards = playedCards.Results;

            return(gamePlay);
        }