/ShipProduct.cs Secret
Last active
November 16, 2023 19:01
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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