public ProductPriceCalculator(Product product, BuyerStrategy buyerStrategy, DiscountStrategy discountStrategy, Price price)
 {
     _product          = product;
     _buyerStrategy    = buyerStrategy;
     _discountStrategy = discountStrategy;
     _price            = price;
 }
 public static DiscountStrategyDto FromDomain(DiscountStrategy strategy) =>
 new DiscountStrategyDto
 {
     Id          = (int)strategy.Id,
     Name        = (string)strategy.Name,
     Description = (string)strategy.Description,
 };
Example #3
0
 public bool ApplyDiscount(ShoppingCart shoppingCart)
 {
     if (shoppingCart.TotalAmount > MinimumAmount)
     {
         DiscountStrategy.ApplyDiscount(shoppingCart, DiscountQuantity);
         return(true);
     }
     return(false);
 }
Example #4
0
        public bool ApplyDiscount(ShoppingCart shoppingCart)
        {
            uint productQuantity = shoppingCart.GetProductQuantityOfCategory(Category);

            if (productQuantity > MinimumItems)
            {
                DiscountStrategy.ApplyDiscount(shoppingCart, DiscountQuantity);
                return(true);
            }
            return(false);
        }
Example #5
0
 public decimal CalculateProductDiscount(Product product)
 {
     return DiscountStrategy == null
         ? 0
         : DiscountStrategy.GetDiscount(product);               
 }