public DisplayProduct(DisplayProductNumber productNumber, Product product) { ProductNumber = productNumber ?? throw new InvalidOperationException(nameof(ProductNumber) + " is required.");; Product = product; DisplayPrice = product.Price; SalableStock = ProductStockQuantity.EmptyQuantity(); }
public DisplayProduct FindWithValidation(DisplayProductNumber displayProductNumber) { var displayProduct = Find(displayProductNumber); if (displayProduct == null) { throw new InvalidOperationException("DisplayProduct is not exists."); } return(displayProduct); }
public SalesStatus GetSalesStatus(DisplayProductNumber displayProductNumber) { var displayProduct = _displayProducts.FindWithValidation(displayProductNumber); if (displayProduct.SoldOut) { return(SalesStatus.SoldOut); } if (_deposit.CanPurches(displayProduct.DisplayPrice)) { return(SalesStatus.Salable); } return(SalesStatus.Unsalable); }
public Product Purchase(DisplayProductNumber displayProductNumber) { var displayProduct = _displayProducts.FindWithValidation(displayProductNumber); if (displayProduct.SoldOut) { return(null); } if (!_deposit.CanPurches(displayProduct.DisplayPrice)) { return(null); } _deposit.StorePurchesdAmount(displayProduct.DisplayPrice); return(displayProduct.Purchase()); }
public void RestockProduct(DisplayProductNumber displayProductNumber, ProductStockQuantity salableStock) { var displayProduct = _displayProducts.FindWithValidation(displayProductNumber); displayProduct.Restock(salableStock); }
public DisplayProduct Find(DisplayProductNumber displayProductNumber) { _displayProducts.TryGetValue(displayProductNumber, out var displayProduct); return(displayProduct); }
public void RestockProduct(DisplayProductNumber displayProductNumber, ProductStockQuantity salableStock) { _displayProducts.Restock(displayProductNumber, salableStock); }
public DisplayProduct(DisplayProductNumber productNumber, Price displayPrice, Product product) : this(productNumber, product) { DisplayPrice = displayPrice; }