public ProductChangeCountCommand(IProductPriceInfo product, int newProductCount)
 {
     if (newProductCount <= 0)
     {
         throw new ArgumentOutOfRangeException(nameof(newProductCount));
     }
     _product         = product ?? throw new ArgumentNullException(nameof(product));
     _oldProductCount = _product.Product.StockQty;
     _newProductCount = newProductCount;
 }
Пример #2
0
        public void ChangeProductQty(IProductPriceInfo product, int newProductQty)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            var changeProductCountCommand = _productCommandFactory.CreateChangeProductCountCommand(product, newProductQty);

            _commandManager.ExecuteCommand(changeProductCountCommand);
        }
Пример #3
0
        public void RemoveProduct(IProductPriceInfo product)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            var removeProductCommand = _productCommandFactory.CreateRemoveProductCommand(Products, product);

            _commandManager.ExecuteCommand(removeProductCommand);
        }
Пример #4
0
        public void SetProductCoupon(IProductPriceInfo product, IProductCoupon coupon)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }
            if (coupon == null)
            {
                throw new ArgumentNullException(nameof(coupon));
            }

            var addCouponCommand = _productCouponFactory.CreateSetCouponCommand(product, coupon);

            _commandManager.ExecuteCommand(addCouponCommand);
        }
        public decimal GetTotalPrice(IProductPriceInfo productInfo)
        {
            if (productInfo == null)
            {
                throw new ArgumentNullException(nameof(productInfo));
            }
            if (productInfo.Product.Price < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(productInfo.Product.Price));
            }
            if (productInfo.InCartQty < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(productInfo.InCartQty));
            }

            var totalPriceWithNoDiscount = productInfo.InCartQty * productInfo.Product.Price;

            return(productInfo.InCartQty >= _minimumProductCountForDiscount
                ? totalPriceWithNoDiscount * (1 - Discount)
                : totalPriceWithNoDiscount);
        }
Пример #6
0
 public SetCouponToProductCommand(IProductPriceInfo product, IProductCoupon newProductCoupon)
 {
     _product        = product;
     _newCoupon      = newProductCoupon;
     _previousCoupon = _product.Coupon;
 }
 public ICommand CreateSetCouponCommand(IProductPriceInfo product, IProductCoupon newCoupon)
 {
     return(new SetCouponToProductCommand(product, newCoupon));
 }
 public ICommand CreateAddProductCommand(IList <IProductPriceInfo> products, IProductPriceInfo product)
 {
     return(new ProductAddCommand(products, product));
 }
 public ICommand CreateChangeProductCountCommand(IProductPriceInfo product, int count)
 {
     return(new ProductChangeCountCommand(product, count));
 }
 public ICommand CreateRemoveProductCommand(IList <IProductPriceInfo> products, IProductPriceInfo product)
 {
     return(new ProductRemoveCommand(products, product));
 }
Пример #11
0
 public ProductRemoveCommand(IList <IProductPriceInfo> products, IProductPriceInfo product)
 {
     _products = products ?? throw new ArgumentNullException(nameof(products));
     _product  = product ?? throw new ArgumentNullException(nameof(product));
 }