public static OrderProduct DecrementQuanityForItemById(ISession session, int id)
        {
            var cart    = ShoppingCartManager.GetCart(session);
            var product = ShoppingCartManager.ItemById(session, id);

            if (product != null)
            {
                var orderProduct = cart.DecrementQuantityForOrderByProductId(id);
                ShoppingCartManager.SaveCart(session, cart);
                return(orderProduct);
            }
            return(null);
        }
        public static Dictionary <string, int> GetQuantity(ISession session, int id)
        {
            var cart    = ShoppingCartManager.GetCart(session);
            var product = ShoppingCartManager.ItemById(session, id);

            if (product != null)
            {
                var dict = new Dictionary <string, int>();
                dict["quantity"] = product.Quantity;
                return(dict);
            }

            return(null);
        }
        public static bool RemoveItemById(ISession session, int id)
        {
            var cart    = ShoppingCartManager.GetCart(session);
            var product = ShoppingCartManager.ItemById(session, id);

            if (product != null)
            {
                cart.RemoveProductById(id);
                ShoppingCartManager.SaveCart(session, cart);
                return(true);
            }

            return(false);
        }
        public static void SetQuantityForItemById(ISession session, int id, int quantity)
        {
            var cart    = ShoppingCartManager.GetCart(session);
            var product = ShoppingCartManager.ItemById(session, id);

            if (product != null)
            {
                // TODO: Use the new methods from the models.
                int index = cart.Order.OrderProducts.IndexOf(product);
                if (index != -1 && cart.Order.OrderProducts.ElementAt(index) != null)
                {
                    cart.Order.OrderProducts[index].SetQuantity(quantity);
                    ShoppingCartManager.SaveCart(session, cart);
                }
            }
        }