Ejemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            // Create an instance of the cart controller
            ProcessFlow.CartController cartController = new ProcessFlow.CartController();
            // Fetch the cart state from the controller
            myCart = cartController.GetCart(false);

            // If there is something in the cart then show the continue button
            link.Visible = myCart.Count > 0;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// A method to return the current state of the cart
        /// </summary>
        /// <param name="create">Specifies whether a cart should be created if one does not exist</param>
        /// <returns>Cart object</returns>
        public Cart GetCart(bool create)
        {
            // Fetch the cart object from session state
            Cart myCart = (Cart)HttpContext.Current.Session[CART_KEY];

            if ( myCart == null ){
                if (create){
                    myCart = new Cart();
                }else{
                    HttpContext.Current.Server.Transfer(URL_NOCART);
                    return null;
                }
            }

            return myCart;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// A method to return the current state of the cart
 /// </summary>
 /// <param name="create">Specifies whether a cart should be created if one does not exist</param>
 /// <returns>Cart object</returns>
 public void StoreCart(Cart cart)
 {
     // Store the cart object in session state
     HttpContext.Current.Session[CART_KEY] = cart;
 }
Ejemplo n.º 4
0
        protected override void OnLoad(EventArgs e)
        {
            // Create an instance of the cart controller
            ProcessFlow.CartController cartController = new ProcessFlow.CartController();

            myCart = cartController.GetCart(true);

            if (!Page.IsPostBack){

                // Get the itemdId from the query string
                string itemId = Request["itemId"];

                if (itemId != null){
                    // Clean the input string
                    itemId = WebComponents.CleanString.InputText(itemId, 50);
                    myCart.Add(itemId);
                    cartController.StoreCart(myCart);

                }
            }

            //Get an account controller
            ProcessFlow.AccountController accountController = new ProcessFlow.AccountController();

            //Get the user's favourite category
            string favCategory = accountController.GetFavouriteCategory();

            //If we have a favourite category, render the favourites list
            if (favCategory != null){
                favorites.Visible = true;
                ViewState[KEY_CATEGORY] = favCategory;
            }

            Refresh();
        }
Ejemplo n.º 5
0
 // Update cart
 private static void SetCartItems(int uniqueID, Cart cart, bool isShoppingCart)
 {
     dal.SetCartItems(uniqueID, cart.CartItems, isShoppingCart);
 }
Ejemplo n.º 6
0
 // Retrieve cart
 private static Cart GetCartItems(string username, bool isShoppingCart)
 {
     Cart cart = new Cart();
     foreach(CartItemInfo cartItem in dal.GetCartItems(username, applicationName, isShoppingCart)) {
         cart.Add(cartItem);
     }
     return cart;
 }