private void CacheData() { List <DevMod.Models.MProductContainer> allProductContainer = new List <DevMod.Models.MProductContainer>(); List <DevMod.Models.MCategory> allCategories = new List <DevMod.Models.MCategory>(); List <DevMod.Models.MPrice> allPrice = new List <DevMod.Models.MPrice>(); List <DevMod.Models.MSubCategory> allSubCategories = new List <DevMod.Models.MSubCategory>(); List <DevMod.Models.MCategoryContainer> allCategoryContainer = new List <DevMod.Models.MCategoryContainer>(); List <DevMod.Models.MBrand> allBrands = new List <DevMod.Models.MBrand>(); List <DevMod.Models.MColor> allColors = new List <DevMod.Models.MColor>(); List <DevMod.Models.MCommon.MViewObjects.MViewProducts> allProducts = new List <DevMod.Models.MCommon.MViewObjects.MViewProducts>(); List <DevMod.Models.MProducts> allCompleteProducts = new List <DevMod.Models.MProducts>(); DevMod.Classes.CProducts ccp = new DevMod.Classes.CProducts(); DevMod.Classes.CSubCategory msc = new DevMod.Classes.CSubCategory(); DevMod.Classes.CCommon.CViewObjects cv = new DevMod.Classes.CCommon.CViewObjects(); DevMod.Classes.CCategory mc = new DevMod.Classes.CCategory(); DevMod.Classes.CCategoryContainer mcc = new DevMod.Classes.CCategoryContainer(); DevMod.Classes.CPrice cp = new DevMod.Classes.CPrice(); DevMod.Classes.CBrand cb = new DevMod.Classes.CBrand(); DevMod.Classes.CColor cc = new DevMod.Classes.CColor(); DevMod.Classes.CProductContainer cpc = new DevMod.Classes.CProductContainer(); allProductContainer = cpc.GetAll(); allPrice = cp.GetAll(); allCompleteProducts = ccp.GetAll(); allSubCategories = msc.GetAll(); allCategories = mc.GetAll(); allCategoryContainer = mcc.GetAll(); allBrands = cb.GetAll(); allColors = cc.GetAll(); allProducts = cv.GetAllProducts(); HttpContext.Current.Cache.Remove("allProductContainer"); HttpContext.Current.Cache.Remove("allCompleteProducts"); HttpContext.Current.Cache.Remove("allPrice"); HttpContext.Current.Cache.Remove("allCategories"); HttpContext.Current.Cache.Remove("allSubCategories"); HttpContext.Current.Cache.Remove("allCategoryContainer"); HttpContext.Current.Cache["allSubCategories"] = allSubCategories; HttpContext.Current.Cache["allCategories"] = allCategories; HttpContext.Current.Cache["allCategoryContainer"] = allCategoryContainer; HttpContext.Current.Cache["allPrice"] = allPrice; HttpContext.Current.Cache["allBrands"] = allBrands; HttpContext.Current.Cache["allColors"] = allColors; HttpContext.Current.Cache["allProducts"] = allProducts; HttpContext.Current.Cache["allCompleteProducts"] = allCompleteProducts; HttpContext.Current.Cache["allProductContainer"] = allProductContainer; }
private void BindAllProductControls(string ProductId) { List <DevMod.Models.MProducts> allProducts = (List <DevMod.Models.MProducts>)HttpContext.Current.Cache["allCompleteProducts"]; string productId = ProductId, productCode = string.Empty, productName = string.Empty, productImage1 = string.Empty, productImage2 = string.Empty, productImage3 = string.Empty, productDescription = string.Empty, productPrice = string.Empty , productDiscountedPrice = string.Empty; if (allProducts.Count > 0) { productDescription = allProducts.Where(o => o.id == productId).Select(o => o.Description).FirstOrDefault(); productCode = allProducts.Where(o => o.id == productId).Select(o => o.Code).FirstOrDefault(); productImage1 = allProducts.Where(o => o.id == productId).Select(o => o.ImageUrl1).FirstOrDefault(); productImage2 = allProducts.Where(o => o.id == productId).Select(o => o.ImageUrl2).FirstOrDefault(); productImage3 = allProducts.Where(o => o.id == productId).Select(o => o.ImageUrl3).FirstOrDefault(); productPrice = allProducts.Where(o => o.id == productId).Select(o => o.Price).FirstOrDefault(); productDiscountedPrice = GetDiscountedRate(productId); lblDescription.Text = productDescription; lblDiscountedPrice.Text = productDiscountedPrice; lblName.Text = productName; lblPrice.Text = productPrice; lblProductCode.Text = productCode; lblProductId.Text = productId; imgLarge.ImageUrl = productImage1; imgZoom1.ImageUrl = productImage1; imgZoom2.ImageUrl = productImage2; imgZoom3.ImageUrl = productImage3; imgZoom1.DataBind(); imgZoom2.DataBind(); imgZoom3.DataBind(); } else { DevMod.Classes.CProducts cp = new DevMod.Classes.CProducts(); allProducts = cp.GetAll(); HttpContext.Current.Cache["allCompleteProducts"] = allProducts; BindAllProductControls(ProductId); } }
private Dictionary <int, string> GetAll(DevMod.Models.MProducts model, DropDownList ddl) { Dictionary <int, string> items = new Dictionary <int, string>(); List <DevMod.Models.MProducts> allBrands = new List <DevMod.Models.MProducts>(); if (HttpContext.Current.Cache["allBrands"] != null) { allBrands = (List <DevMod.Models.MProducts>)HttpContext.Current.Cache["allProducts"]; } else { DevMod.Classes.CProducts cb = new DevMod.Classes.CProducts(); allBrands = cb.GetAll(); } foreach (var item in allBrands) { items.Add(Convert.ToInt32(item.id), item.Name1); } ddl.DataTextField = "Value"; ddl.DataValueField = "Key"; ddl.DataSource = items; ddl.DataBind(); return(items); }