public async Task <IActionResult> Post([FromBody] AddGreetingRequest request) { var newGreetingId = Guid.NewGuid(); var addGreetingCommand = new AddGreetingCommand(newGreetingId, request.Message); await _commandProcessor.SendAsync(addGreetingCommand); var addedGreeting = await _queryProcessor.ExecuteAsync(new GreetingsByIdQuery(newGreetingId)); return(Ok(addedGreeting)); }
public async Task <IActionResult> AddGreeting() { var command = new AddGreetingCommand() { GreetingMessage = "Welcome to the Example.", ThrowError = false }; var failingCommand = new AddGreetingCommand() { GreetingMessage = "This should never reach the DB or outbox.", ThrowError = true }; await _commandProcessor.PostAsync(command); await _commandProcessor.PostAsync(failingCommand); return(View("Index")); }