-
-
Save dcomartin/f32b5bc39f3e72c09251aac075ea282b to your computer and use it in GitHub Desktop.
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