public async Task <IHttpActionResult> GetContext(Guid?id)
        {
            if (!id.HasValue)
            {
                return(new ResponseMessageResult(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.NotFound
                }));
            }

            var response = await _mediator.Send(new ReadContext { ContextId = id.Value });

            if (response is FailedResponse <Context> )
            {
                return(new ResponseMessageResult(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.NotFound
                }));
            }

            var message = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ObjectContent <Context>(response.Result, new JsonMediaTypeFormatter())
            };

            return(ResponseMessage(message));
        }
        private async Task TheCharacterIsCreated()
        {
            _characterCommand.Traits = _traits;
            var response = await _mediator.Send(_characterCommand);

            response.Should().NotBeNull();
            _characterId = response.Result;
        }
        private async Task TheStoryIsCreated()
        {
            var response = await _mediator.Send(_story);

            response.Should().NotBeNull();

            _storyId = response.Result;
        }
        public async Task TheEnvironmentIsCreated()
        {
            var response = await _mediator.Send(_globalEnvironment);

            response.Should().NotBeNull();
            _environmentId = response.Result;
            _environmentId.Should().NotBeEmpty();
        }
        private async Task TheItemsAreCreated()
        {
            _itemIds = new List <Guid>();
            foreach (var createItem in _items)
            {
                var response = await _mediator.Send(createItem);

                _itemIds.Add(response.Result);
            }
        }
        private async Task CreatingAContext()
        {
            _contextCommand = FightingFantasyContext.FightingFantasyContextCommand;

            var quickContextCommand = new QuickContext
            {
                Context = _contextCommand,
                CharacterTypes = _characterTypes,
                ItemTypes = _itemTypes
            };

            var response = await _mediator.Send(quickContextCommand);
            response.Should().NotBeNull();
            response.Result.Should().NotBeEmpty();
            _contextId = response.Result;
        }
Пример #7
0
        public async Task <Guid> Handle(QuickContext command)
        {
            var contextResponse = await _mediator.Send(command.Context);

            foreach (var commandItemType in command.ItemTypes)
            {
                commandItemType.ContextId = contextResponse.Result;
                await _mediator.Send(commandItemType);
            }

            foreach (var commandCharacterType in command.CharacterTypes)
            {
                commandCharacterType.ContextId = contextResponse.Result;
                await _mediator.Send(commandCharacterType);
            }

            return(contextResponse.Result);
        }
Пример #8
0
        public async Task <IHttpActionResult> Get()
        {
            var response = await _mediator.Send(new ViewStories());

            if (response is FailedResponse <IEnumerable <Story> > )
            {
                return(new ResponseMessageResult(new HttpResponseMessage {
                    StatusCode = HttpStatusCode.NotFound
                }));
            }

            var message = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ObjectContent <IEnumerable <Story> >(response.Result, new JsonMediaTypeFormatter())
            };

            return(ResponseMessage(message));
        }