Skip to content

Instantly share code, notes, and snippets.

Created October 14, 2021 21:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dcomartin/350b97fc74e12d5c3f3fc153f1c4764c to your computer and use it in GitHub Desktop.
public record QuickOrderCommand(Sku Sku, int Quantity, Version Version);
public class QuickOrderHandler : IRequestHandler<QuickOrderCommand>
private readonly ICatalogService _catalogService;
private readonly IWarehouseService _warehouseService;
private readonly IOrderRepository _orderRepository;
public QuickOrderHandler(ICatalogService catalogService,
IWarehouseService warehouseService, IOrderRepository orderRepository)
_catalogService = catalogService;
_warehouseService = warehouseService;
_orderRepository = orderRepository;
public async Task Handle(QuickOrderCommand request)
if (await _warehouseService.QuantityOnHand(request.Sku) <= 0)
throw new InvalidOperationException("Product has no quantity on hand.");
var price = await _catalogService.Price(request.Sku);
var quickOrder = new QuickOrder(request.Sku, price);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment