// POST api/products
 public void Post(ShoppingCartElement cartElement)
 {
     if (cartElement != null)
     {
         var command = new AddQuantityCommand();
         command.ProductId = cartElement.ProductId;
         command.Quantity = cartElement.Quantity;
         commandProxy.Store(command);
         commandProxy.Process();
     }
 }
        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);
        }
 public static void Save(ShoppingCartElement element)
 {
     cartElements.RemoveAll(x => x.ProductId == element.ProductId);
     cartElements.Add(element);
 }