public DisplayProduct(DisplayProductNumber productNumber, Product product)
 {
     ProductNumber = productNumber ?? throw new InvalidOperationException(nameof(ProductNumber) + " is required.");;
     Product       = product;
     DisplayPrice  = product.Price;
     SalableStock  = ProductStockQuantity.EmptyQuantity();
 }
예제 #2
0
        public DisplayProduct FindWithValidation(DisplayProductNumber displayProductNumber)
        {
            var displayProduct = Find(displayProductNumber);

            if (displayProduct == null)
            {
                throw new InvalidOperationException("DisplayProduct is not exists.");
            }
            return(displayProduct);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
        }
예제 #5
0
        public void RestockProduct(DisplayProductNumber displayProductNumber, ProductStockQuantity salableStock)
        {
            var displayProduct = _displayProducts.FindWithValidation(displayProductNumber);

            displayProduct.Restock(salableStock);
        }
예제 #6
0
 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;
 }