Example #1
0
        private void GetByBaseCategoryId()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["bc"]))
            {
                int baseCatId = Convert.ToInt32(Business.Encryption.Encryption64.Decrypt(Request.QueryString["bc"], "!#$a54?3"));
                if (baseCatId != 0)
                {
                    CategoryEntity category = new CategoryAdapter().GetCategoryById(baseCatId);
                    BaseCategoryNameLabel.Text = category.Name;
                    CategoryNameLabel.Text     = category.Name;

                    SubCategoriesRepeater.DataSource = new CategoryAdapter().GetSubCategories(baseCatId);
                    SubCategoriesRepeater.DataBind();

                    ProductListRepeater.DataSource = new ProductAdapter().GetProductsByMainCategoryId(baseCatId);
                    ProductCollection productList = (ProductCollection)ProductListRepeater.DataSource;
                    Session["ProductList"] = productList;
                    ProductListRepeater.DataBind();
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
        }
Example #2
0
        private void BindSubCategories(List <Category> categories)
        {
            int     categoriesCount = categories.Count;
            decimal numOfColumns    = Math.Ceiling(decimal.Divide(categoriesCount, 5));

            if (numOfColumns > 5)
            {
                numOfColumns = 5;
            }

            categories.Sort((a, b) => a.Name.CompareTo(b.Name));

            SubCategoriesRepeater.RepeatColumns = (int)numOfColumns;
            SubCategoriesRepeater.DataSource    = categories;
            SubCategoriesRepeater.DataBind();
        }
Example #3
0
        private void GetByKeywordAndBaseCategory()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["k"]) && !string.IsNullOrEmpty(Request.QueryString["bc"]))
            {
                string keyword   = Business.Encryption.Encryption64.Decrypt(Request.QueryString["k"], "12345678").Replace("+", " ");
                int    baseCatId = Convert.ToInt32(Business.Encryption.Encryption64.Decrypt(Request.QueryString["bc"], "!#$a54?3"));
                if (baseCatId != 0)
                {
                    CategoryEntity category = new CategoryAdapter().GetCategoryById(baseCatId);
                    BaseCategoryNameLabel.Text = category.Name;
                    CategoryNameLabel.Text     = keyword;

                    SubCategoriesRepeater.DataSource = new CategoryAdapter().GetSubCategories(baseCatId);
                    SubCategoriesRepeater.DataBind();

                    ProductListRepeater.DataSource = new ProductAdapter().GetProductsByKeywordAndBaseCatId(keyword, baseCatId);
                    ProductCollection productList = (ProductCollection)ProductListRepeater.DataSource;
                    Session["ProductList"] = productList;
                    ProductListRepeater.DataBind();
                }
                else
                {
                    BaseCategoryNameLabel.Text = keyword;
                    CategoryNameLabel.Text     = keyword;
                    ProductCollection products = new ProductAdapter().GetProductsByKeyword(keyword);
                    Session["ProductList"] = products;
                    //Disable CategorySlider
                    SubCategoriesRepeater.Visible = false;

                    ProductListRepeater.DataSource = products;
                    ProductListRepeater.DataBind();
                }
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
        }