예제 #1
0
        public async Task <IActionResult> CompleteAsync(Guid id, [FromBody] CompleteTodoCommand command)
        {
            if (id != command.Id)
            {
                throw new Exception("Url id param and request doesn't match");
            }

            await requestSender.Send(command);

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> Complete([FromBody] CompleteTodoCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(ErrorModelResult());
            }
            try
            {
                var result = await _commandDispatcher.DispatchAsync <CompleteTodoCommand, Result>(command);

                return(ToResult(result));
            }
            catch (FailureResult reqEx)
            {
                return(ErrorResult(reqEx));
            }
        }