Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Last active November 16, 2023 19:01
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/f32b5bc39f3e72c09251aac075ea282b to your computer and use it in GitHub Desktop.
Save dcomartin/f32b5bc39f3e72c09251aac075ea282b to your computer and use it in GitHub Desktop.
public void ShipProduct(int quantity)
{
// Trivial Validation
if (quantity <= 0)
{
throw new InvalidDomainException("Quantity must be greater than zero.");
}
// Business Rule
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