Exemplo n.º 1
0
        public async Task <VisibleFieldType[][]> HandleAsync(GetVisibleGameTableRequest request, CancellationToken cancellationToken)
        {
            using (var session = _documentStore.OpenAsyncSession())
            {
                // TODO: Validate user id
                var game = await session.LoadGameAsync(request.GameId, cancellationToken).ConfigureAwait(false);

                return(EnumArrayCloner.CloneAndMap(game.VisibleTable, FieldTypeConverter.ToContract));
            }
        }
Exemplo n.º 2
0
        public async Task <MarkTypes[][]> HandleAsync(GetPlayerMarksRequest request, CancellationToken cancellationToken)
        {
            using (var session = _documentStore.OpenAsyncSession())
            {
                var playerMarksDocument = await session.LoadPlayerMarksAsync(request.GameId, request.PlayerId, cancellationToken).ConfigureAwait(false);

                if (playerMarksDocument == null)
                {
                    throw new ActionNotAllowedException("You are not involved in that game.");
                }

                return(EnumArrayCloner.CloneAndMap(playerMarksDocument.Marks, MarkTypeConverter.ToContract));
            }
        }