예제 #1
0
        private void HandleNewCartItem(ShopCartItem item)
        {
            var cartItem = new ShopCartClient(_user.GetUserId());

            cartItem.AddItem(item);

            ValidatingShopCart(cartItem);
            _context.ShopCartClients.Add(cartItem);
        }
예제 #2
0
        private void HandlerExistentShopCart(ShopCartClient cart, ShopCartItem item)
        {
            var productItemExistent = cart.ShopCartItemExists(item);

            cart.AddItem(item);
            ValidatingShopCart(cart);

            if (productItemExistent)
            {
                _context.ShopCartItems.Update(cart.GetByProductId(item.ProductId));
            }
            else
            {
                _context.ShopCartItems.Add(item);
            }

            _context.ShopCartClients.Update(cart);
        }