public EventPublisher(QuantityAdditionFailedEventHandler quantityAdditionFailedEventHandler,
     QuantityAddedDbEventHandler quantityAddedDbEventHandler,
     ClearShoppingCartEventHandler clearShoppingCartEventHandler)
 {
     this.quantityAdditionFailedEventHandler = quantityAdditionFailedEventHandler;
     this.quantityAddedDbEventHandler = quantityAddedDbEventHandler;
     this.clearShoppingCartEventHandler = clearShoppingCartEventHandler;
 }
Example #2
0
 public EventPublisher(QuantityAdditionFailedEventHandler quantityAdditionFailedEventHandler,
                       QuantityAddedDbEventHandler quantityAddedDbEventHandler,
                       ClearShoppingCartEventHandler clearShoppingCartEventHandler)
 {
     this.quantityAdditionFailedEventHandler = quantityAdditionFailedEventHandler;
     this.quantityAddedDbEventHandler        = quantityAddedDbEventHandler;
     this.clearShoppingCartEventHandler      = clearShoppingCartEventHandler;
 }
        public ShoppingCart GetShoppingCart(int productId)
        {
            var shoppingCartElement = ShoppingCartRepository.Get(productId);

            if (shoppingCartElement == null)
            {
                shoppingCartElement = new ShoppingCartElement();
                shoppingCartElement.ProductId = productId;
                shoppingCartElement.Quantity = 0;
            }

            var quantityAdditionFailedEventHandler = new QuantityAdditionFailedEventHandler();
            var quantityAddedDbEventHandler = new QuantityAddedDbEventHandler();
            var clearShoppingCartEventHandler = new ClearShoppingCartEventHandler();
            return new ShoppingCart(new EventPublisher(quantityAdditionFailedEventHandler, quantityAddedDbEventHandler, clearShoppingCartEventHandler),
                shoppingCartElement.ProductId,
                shoppingCartElement.Quantity);
        }
Example #4
0
        public ShoppingCart GetShoppingCart(int productId)
        {
            var shoppingCartElement = ShoppingCartRepository.Get(productId);

            if (shoppingCartElement == null)
            {
                shoppingCartElement           = new ShoppingCartElement();
                shoppingCartElement.ProductId = productId;
                shoppingCartElement.Quantity  = 0;
            }

            var quantityAdditionFailedEventHandler = new QuantityAdditionFailedEventHandler();
            var quantityAddedDbEventHandler        = new QuantityAddedDbEventHandler();
            var clearShoppingCartEventHandler      = new ClearShoppingCartEventHandler();

            return(new ShoppingCart(new EventPublisher(quantityAdditionFailedEventHandler, quantityAddedDbEventHandler, clearShoppingCartEventHandler),
                                    shoppingCartElement.ProductId,
                                    shoppingCartElement.Quantity));
        }