Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created November 16, 2023 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/c74588bc338fc051b46eeddf49a10481 to your computer and use it in GitHub Desktop.
Save dcomartin/c74588bc338fc051b46eeddf49a10481 to your computer and use it in GitHub Desktop.
public void ShipProduct(int quantity)
{
if (quantity <= 0)
{
throw new InvalidDomainException("Quantity must be greater than zero.");
}
if (quantity > _warehouseProductState.QuantityOnHand)
{
throw new InvalidDomainException("Cannot Ship to a negative Quantity on Hand.");
}
var productShipped = new ProductShipped(Sku, quantity, DateTime.UtcNow);
Apply(productShipped);
Add(productShipped);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment