Ejemplo n.º 1
0
 public HandleAddProduct(
     IRepository <Cart> cartRepository,
     IProductPriceCalculator productPriceCalculator
     )
 {
     this.cartRepository         = cartRepository;
     this.productPriceCalculator = productPriceCalculator;
 }
Ejemplo n.º 2
0
        public CartCommandHandler(
            IRepository <Cart> cartRepository,
            IProductPriceCalculator productPriceCalculator)
        {
            Guard.Against.Null(cartRepository, nameof(cartRepository));
            Guard.Against.Null(productPriceCalculator, nameof(productPriceCalculator));

            this.cartRepository         = cartRepository;
            this.productPriceCalculator = productPriceCalculator;
        }
Ejemplo n.º 3
0
    public void AddProduct(
        IProductPriceCalculator productPriceCalculator,
        ProductItem productItem)
    {
        if (Status != CartStatus.Pending)
        {
            throw new InvalidOperationException($"Adding product for the cart in '{Status}' status is not allowed.");
        }

        var pricedProductItem = productPriceCalculator.Calculate(productItem).Single();

        var @event = ProductAdded.Create(Id, pricedProductItem);

        Enqueue(@event);
        Apply(@event);
    }
Ejemplo n.º 4
0
 public MilkDiscountPriceDecorator(IProductPriceCalculator productPriceCalculator)
     : base(productPriceCalculator)
 {
 }
Ejemplo n.º 5
0
 public ProductPriceCalculatorDec(IProductPriceCalculator productPriceCalculator)
 {
     _productPriceCalculator = productPriceCalculator;
     Items            = productPriceCalculator.Items;
     AppliedDiscounts = productPriceCalculator.AppliedDiscounts;
 }
Ejemplo n.º 6
0
 public Checkout(IProductRepository productRepository, IBasket basket, IProductPriceCalculator productPriceCalculator)
 {
     this.productRepository      = productRepository;
     this.basket                 = basket;
     this.productPriceCalculator = productPriceCalculator;
 }