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; }
public void ChangeProductQty(IProductPriceInfo product, int newProductQty) { if (product == null) { throw new ArgumentNullException(nameof(product)); } var changeProductCountCommand = _productCommandFactory.CreateChangeProductCountCommand(product, newProductQty); _commandManager.ExecuteCommand(changeProductCountCommand); }
public void RemoveProduct(IProductPriceInfo product) { if (product == null) { throw new ArgumentNullException(nameof(product)); } var removeProductCommand = _productCommandFactory.CreateRemoveProductCommand(Products, product); _commandManager.ExecuteCommand(removeProductCommand); }
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); }
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)); }
public ProductRemoveCommand(IList <IProductPriceInfo> products, IProductPriceInfo product) { _products = products ?? throw new ArgumentNullException(nameof(products)); _product = product ?? throw new ArgumentNullException(nameof(product)); }