public static string ClearCart(ISession session) { var cart = ShoppingCartManager.GetCart(session); cart.ClearAllItems(); return(ShoppingCartManager.SaveCart(session, cart)); }
public static OrderProduct AddItemById(ISession session, int id) { var cart = ShoppingCartManager.GetCart(session); var product = cart.AddProductById(id); ShoppingCartManager.SaveCart(session, cart); return(product); }
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 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); } } }