Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
                }
            }
        }