public async Task <IActionResult> Post(CancellationToken cancellationToken) { object result = null; await _httpRequestParser.Parse(HttpContext.Request, async (command, ct) => await _commandReceiver.ReceiveAsync(command, ct), async (query, ct) => result = await _queryReceiver.ReceiveAsync((dynamic)query, ct), async (@event, ct) => await _eventReceiver.ReceiveAsync(@event, ct), cancellationToken); return(result == null ? (IActionResult)Ok() : Ok(JsonConvert.SerializeObject(result, Formatting.None))); }
public async Task <IActionResult> Get(CancellationToken cancellationToken) { await _receiver.ReceiveAsync(new TestCommand("data"), cancellationToken); return(Ok($"OK : {_clock.UtcNow.ToString(CultureInfo.InvariantCulture)}")); }
public async Task ReceiveAsync <TCommand>(TCommand command, CancellationToken cancellationToken = default) where TCommand : ICommand { UpdateCorrelation(command.CommandId); await _next.ReceiveAsync(command, cancellationToken); }