using System; using SlimDomainModel; namespace EventSourcing.Demo.Large { public class WarehouseProduct { public string Sku { get; private set; } public string Name { get; private set; } public string Description { get; private set; } public decimal Price { get; private set; } public int QuantityOnHand { get; private set; } public void SetName(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Name cannot be blank."); } Name = name; } public void SetDescription(string description) { Description = description; } public void SetPrice(decimal price) { if (price < 0) { throw new ArgumentException("Price must be greater than 0."); } Price = price; } public void ShipProduct(int quantity) { if (quantity > QuantityOnHand) { throw new InvalidDomainException("Ah... we don't have enough product to ship!"); } QuantityOnHand -= quantity; } public void ReceiveProduct(int quantity) { QuantityOnHand += quantity; } public void AdjustInventory(int quantity) { if (QuantityOnHand + quantity < 0) { throw new InvalidDomainException("Cannot adjust to a negative quantity on hand."); } QuantityOnHand += quantity; } } }