Skip to content

Instantly share code, notes, and snippets.

Last active Nov 28, 2021
What would you like to do?
public async Task Handle(ProductStockChanged stockChangedEvent)
var product = await productRepository.GetBy(stockChangedEvent.ProductId);
var purchaseOrderLine = await purchaseOrderLineRepository.GetBy(stockChangedEvent.PurchaseOrderLineId);
// validation...
if (stockChangedEvent.IsStockRaised)
product.Stock += stockChangedEvent.Quantity;
purchaseOrderLine.QuantityDelivered += stockChangedEvent.Quantity;
await purchaseOrderLineRepository.Update(purchaseOrderLine);
await productRepository.Save(product);
product.Stock -= stockChangedEvent.Quantity; // stock decrements don't affect purchase deliveries
// trigger a use case that depends on updated product and purchase order line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment