public InventoryItem(ProductId productId, int quantity, decimal price) { this.ProductId = productId; this.Quantity = quantity; this.Price = price; }
private InventoryItem GetProduct(ProductId productId) { return(this.items.Single(i => i.ProductId == productId)); }
public void Reserve(ProductId productId, int quantity) { GetProduct(productId).ReservedCount = quantity; }
public decimal PriceFor(ProductId productId) { return(GetProduct(productId).Price); }
public bool CheckAvailability(ProductId productId, int quantity) { return(AvailableQuantity(productId) >= quantity); }
public void Add(ProductId productId, int quantity, decimal price) { this.items.Add(new InventoryItem(productId, quantity, price)); }