I'm adding the option to use a custom handler or service instead of the default command handler that needs to implement the default command handler interface:
var command = new CreateProduct
{
Name = Product.Name,
Description = Product.Description,
Price = Product.Price
};
// Option 1 - The dispatcher will automatically resolve the command handler (ICommandHandlerAsync<CreateProduct>)
await _dispatcher.SendAsync(command);
// Option 2 - Use your custom command handler or service
await _dispatcher.SendAsync(command, () => _productService.CreateProductAsync(command));
I'm adding the option to use a custom handler or service instead of the default command handler that needs to implement the default command handler interface: