public Task <ICommandResult> HandleCommandAsync(SalesOrderState s, RaiseSalesOrderCommand c, CancellationToken ct) { if (s.SalesOrder != null) { return(CommandResult.FromErrorIAsync("Duplicate sales order id.")); } var e = new SalesOrderRaisedEvent( BusinessEventMetadata.FromCausalId(c.GetCommandId()), c.SalesOrderId, c.CustomerName, c.CustomerEmail, c.Price ); return(CommandResult.FromEventIAsync(e)); }
public Task <IActionResult> RaiseSalesOrder([FromBody] RaiseSalesOrderCommand c) => CommandProcessor.ProcessCommandAsync(_ar, c);