Пример #1
0
        public async Task <IActionResult> Create(string appId, [FromBody] ContentCollection contentCollection)
        {
            var command = new SaveContentCollectionCommand(appId, contentCollection);
            var result  = await _dispatcher.ExecuteCommand(command);

            return(this.HandleCreateCommandResult(result, contentCollection.Id, contentCollection));
        }
Пример #2
0
        public async Task <IActionResult> Create([FromBody] CreateAppCommand command)
        {
            var result = await _dispatcher.ExecuteCommand(command);

            var id = (result.ResultData as App)?.Id;

            return(this.HandleCreateCommandResult(result, id, result.ResultData));
        }
Пример #3
0
        public async Task <IActionResult> Create(string appId, [FromBody] SaveContentItemCommand contentItemCommand)
        {
            contentItemCommand.AppId = appId;
            var result = await _dispatcher.ExecuteCommand(contentItemCommand);

            var id = (result.ResultData as ContentItem)?.Id;

            return(this.HandleCreateCommandResult(result, id, result.ResultData));
        }
Пример #4
0
        public async Task <IActionResult> CreateApiKey(string appId, [FromBody] CreateApiKeyCommand command)
        {
            command.AppId = appId;
            var result = await _dispatcher.ExecuteCommand(command);

            var resultData = result.ResultData as CreateApiKeyResultData;

            if (resultData != null)
            {
                var uri     = $"{appId}/apikeys/{resultData.ApiKey.Id}";
                var payload = new { ApiKey = resultData.ReadableKey };
                return(this.HandleCreateCommandResult(result, uri, payload));
            }
            else
            {
                return(this.HandleCreateCommandResult(result, null, null));
            }
        }
Пример #5
0
        public async Task Executes_all_pipes_PipelineContext()
        {
            await _dispatcher.ExecuteCommand <DoWorkCommand>(new DoWorkCommand());

            PipeVerify.PipesCalled.ShouldContain(x => x == typeof(DoWorkCommandPipe));
        }
Пример #6
0
        public async Task Should_call_handler()
        {
            await _dispatcher.ExecuteCommand(new DoMoreWork());

            DoMoreWorkHandler.WasCalled.ShouldBeTrue();
        }
Пример #7
0
 public async Task ExecuteCommand(ICommand command)
 {
     await _dispatcher.ExecuteCommand(command);
 }