示例#1
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();
        }
 // 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;
 }