Ejemplo n.º 1
0
        protected void PageChanged(object sender, DataGridPageChangedEventArgs e)
        {
            items.CurrentPageIndex = e.NewPageIndex;

            // Get the productId from the query string
            string productId = WebComponents.CleanString.InputText(Request["productId"], 50);

            // Array for the data
            IList <ItemInfo> itemsByProduct = null;

            // Check if the data exists in the data cache
            if (Cache[productId] != null)
            {
                itemsByProduct = (IList <ItemInfo>)Cache[productId];
            }
            else
            {
                // If the data is not in the cache then fetch the data from the business logic tier
                CartItem item = new CartItem();
                itemsByProduct = item.GetItemsByProduct(productId);
                // store the output in the data cache with a 12 hour expiry
                Cache.Add(productId, itemsByProduct, null, DateTime.Now.AddHours(12), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
            }

            // Set the control datasource
            items.DataSource = itemsByProduct;

            // If there is data fetch the product name
            if (itemsByProduct.Count > 0)
            {
                productName.Text = ((ItemInfo)itemsByProduct[0]).ProductName;
            }

            // Bind the data to the the control
            items.DataBind();
        }
Ejemplo n.º 2
0
        public ActionResult Items(string id)
        {
            CartItem bo = new CartItem();

            return(View(bo.GetItemsByProduct(id)));
        }