コード例 #1
0
        public PartialViewResult PageCountingPartialView(long id)
        {
            string  SearchCookieValue = Services.GetCookie(this.HttpContext, "ProductCatWiseCatId").Value;
            dynamic _data             = SearchCookieValue;
            var     json         = JsonConvert.DeserializeObject <Dictionary <string, object> >(_data);
            int     ProductCatId = int.Parse(json["ProductCatId"].ToString());
            int     pageindex    = (int)id;

            ViewBag.LowerLimit = ((pageindex / 5) * 5) + 1;
            ViewBag.PageIndex  = pageindex;

            var SearchProductList = new List <ProductModel>();

            if (!CommonFile.IsParentCategory(ProductCatId))
            {
                SearchProductList = ListAllProduct.Where(x => x.ProductCatId == ProductCatId).ToList();
            }
            else
            {
                SearchProductList = ListAllProduct.Where(x => x.ParentCatId == ProductCatId).ToList();
            }
            ViewBag.UsersProduct = SearchProductList.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
            ViewBag.ProductsFrom = ((pageindex - 1) * Constant.NumberOfProducts) + 1;

            ViewBag.ToProductsCount   = Enumerable.Count(ViewBag.UsersProduct);
            ViewBag.SearchResultCount = SearchProductList.Count;
            ViewBag.NumberOfPages     = SearchProductList.Count / 10;
            return(PartialView("~/Views/ProductCatWise/PageCountingPartialView.cshtml"));
        }
コード例 #2
0
        public PartialViewResult NextPage(long id, string sortingby)
        {
            string  SearchCookieValue = Services.GetCookie(this.HttpContext, "ProductCatWiseCatId").Value;
            dynamic _data             = SearchCookieValue;
            var     json         = JsonConvert.DeserializeObject <Dictionary <string, object> >(_data);
            int     ProductCatId = int.Parse(json["ProductCatId"].ToString());
            int     pageindex    = (int)id;

            ViewBag.LowerLimit = ((pageindex / 5) * 5) + 1;
            ViewBag.PageIndex  = pageindex;

            var SearchProductList = new List <ProductModel>();

            if (!CommonFile.IsParentCategory(ProductCatId))
            {
                if (sortedproducts != null)
                {
                    SearchProductList = sortedproducts;
                }
                else
                {
                    SearchProductList = ListAllProduct.Where(x => x.ProductCatId == ProductCatId).ToList();
                }
            }
            else
            {
                SearchProductList = ListAllProduct.Where(x => x.ParentCatId == ProductCatId).ToList();
            }
            ViewBag.UsersProduct = SearchProductList.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);

            return(PartialView("~/Views/ProductCatWise/PartialCatwiseProductValue.cshtml"));
        }
コード例 #3
0
        public PartialViewResult PartialCatwiseProductValue(string id)

        {
            long?Id          = Convert.ToInt64(CommonFile.Decode(id));
            var  jsonString1 = "{\"ProductCatId\":\"" + Id + "\"}";

            Services.SetCookie(this.ControllerContext.HttpContext, "ProductCatWiseCatId", jsonString1.ToString());
            ProductModel        objModel          = new ProductModel();
            List <ProductModel> SearchProductList = new List <ProductModel>();

            if (Id == null)
            {
                SearchProductList = ListAllProduct;
            }
            else
            {
                objModel.ProductCatId = Convert.ToInt64(Id);
                if (!CommonFile.IsParentCategory(Id))
                {
                    SearchProductList = ListAllProduct.Where(x => x.ProductCatId == Id).ToList();
                }
                else
                {
                    SearchProductList = ListAllProduct.Where(x => x.ParentCatId == Id).ToList();
                }
            }
            ViewBag.LowerLimit        = 1;
            ViewBag.UsersProduct      = SearchProductList.Take(12);
            ViewBag.NumberOfPages     = SearchProductList.Count / 10;
            ViewBag.SearchResultCount = SearchProductList.Count;
            var ProductCatList = CommonFile.GetProductCategory(Id);

            //var ProductListMdel = new List<DropDownModel>();
            return(PartialView("~/Views/ProductCatWise/PartialCatwiseProductValue.cshtml", objModel));
        }
コード例 #4
0
        public PartialViewResult LazyLoader(int pageindex, string sortingby)
        {
            string  SearchCookieValue = Services.GetCookie(this.HttpContext, "ProductCatWiseCatId").Value;
            dynamic _data             = SearchCookieValue;
            var     json              = JsonConvert.DeserializeObject <Dictionary <string, object> >(_data);
            int     ProductCatId      = int.Parse(json["ProductCatId"].ToString());
            var     SearchProductList = new List <ProductModel>();

            if (!CommonFile.IsParentCategory(ProductCatId))
            {
                if (sortingby == "1")
                {
                    SearchProductList = ListAllProduct.Where(x => x.ProductCatId == ProductCatId).OrderBy(x => x.DiscountPrice).ToList();
                }
                if (sortingby == "2")
                {
                    SearchProductList = ListAllProduct.Where(x => x.ProductCatId == ProductCatId).OrderByDescending(x => x.DiscountPrice).ToList();
                }
                if (sortingby == "3")
                {
                    SearchProductList = ListAllProduct.Where(x => x.ProductCatId == ProductCatId).OrderByDescending(x => x.Id).ToList();
                }
                if (sortingby == "")
                {
                    SearchProductList = ListAllProduct.Where(x => x.ProductCatId == ProductCatId).ToList();
                }
            }
            else
            {
                if (sortingby == "1")
                {
                    SearchProductList = ListAllProduct.Where(x => x.ParentCatId == ProductCatId).OrderBy(x => x.DiscountPrice).ToList();
                }
                if (sortingby == "2")
                {
                    SearchProductList = ListAllProduct.Where(x => x.ParentCatId == ProductCatId).OrderByDescending(x => x.DiscountPrice).ToList();
                }
                if (sortingby == "3")
                {
                    SearchProductList = ListAllProduct.Where(x => x.ParentCatId == ProductCatId).OrderByDescending(x => x.Id).ToList();
                }
                if (sortingby == "")
                {
                    SearchProductList = ListAllProduct.Where(x => x.ParentCatId == ProductCatId).ToList();
                }
            }
            ViewBag.LazyLoaderProducts = SearchProductList.Skip((pageindex) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
            return(PartialView("~/Views/Shared/LazyLoaderProducts.cshtml"));
        }
コード例 #5
0
        public PartialViewResult MorePages(long id)
        {
            ProductModel objmodel  = new ProductModel();
            int          pageindex = (int)id;

            ViewBag.PageIndex = pageindex;
            HeaderPartialModel objModel = new HeaderPartialModel();

            if (pageindex % 5 == 0)
            {
                ViewBag.LowerLimit = ((pageindex / 5));
            }
            else
            {
                ViewBag.LowerLimit = ((pageindex / 5) * 5) + 1;
            }

            #region  For binding products in next page


            if (String.IsNullOrWhiteSpace(objModel.SearchBarText))
            {
                if (objModel.ParentCatId == 0)
                {
                    var SearchProductList = new List <ProductModel>();
                    var ProductCatId      = Services.GetCookie(this.HttpContext, "ProductCatId").Value;
                    if (!CommonFile.IsParentCategory(long.Parse(CommonFile.Decode(ProductCatId))))
                    {
                        if (sortedproducts != null)
                        {
                            SearchProductList = sortedproducts;
                        }
                        else
                        {
                            SearchProductList = ListAllProduct.Where(x => x.ProductCatId == long.Parse(CommonFile.Decode(ProductCatId))).ToList();
                        }
                    }
                    else
                    {
                        SearchProductList = ListAllProduct.Where(x => x.ParentCatId == long.Parse(CommonFile.Decode(ProductCatId))).ToList();
                    }
                    ViewBag.UsersProduct      = SearchProductList.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
                    ViewBag.SearchResultCount = SearchProductList.Count;
                    if ((ViewBag.SearchResultCount / Constant.NumberOfProducts) < (pageindex + 4))
                    {
                        if ((ViewBag.SearchResultCount % Constant.NumberOfProducts) != 0)
                        {
                            ViewBag.NumberOfPages = (ViewBag.SearchResultCount / Constant.NumberOfProducts) + 1;
                        }
                        else
                        {
                            ViewBag.NumberOfPages = (ViewBag.SearchResultCount / Constant.NumberOfProducts);
                        }
                    }
                    else
                    {
                        ViewBag.NumberOfPages = ViewBag.LowerLimit + 4;
                    }
                    ViewBag.ProductsFrom = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
                    string NumberOfPages1     = ViewBag.NumberOfPages.ToString();
                    string LowerLimit1        = ViewBag.LowerLimit.ToString();
                    string SearchResultCount1 = ViewBag.SearchResultCount.ToString();
                    ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
                    Services.SetCookie(this.ControllerContext.HttpContext, "NumberOfPages", NumberOfPages1);
                    Services.SetCookie(this.ControllerContext.HttpContext, "LowerLimit", LowerLimit1);
                    Services.SetCookie(this.ControllerContext.HttpContext, "SearchResutlCount", SearchResultCount1);
                    return(PartialView("~/Views/ProductCatWise/PartialCatwiseProductValue.cshtml"));
                }
                var SearchListWithCategory = ListAllProduct.Where(x => x.ParentCatId.Equals(objModel.ParentCatId)).ToList();
                ViewBag.UsersProduct      = SearchListWithCategory.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
                ViewBag.SearchResultCount = SearchListWithCategory.Count;
                if ((ViewBag.SearchResultCount / 10) < (pageindex + 4))
                {
                    ViewBag.NumberOfPages = ViewBag.LowerLimit + ((ViewBag.SearchResultCount - 5) - 1);
                }
                else
                {
                    ViewBag.NumberOfPages = pageindex + 4;
                }
                ViewBag.ProductsFrom    = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
                ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
                string NumberOfPages2     = ViewBag.NumberOfPages;
                string LowerLimit2        = ViewBag.LowerLimit;
                string SearchResultCount2 = ViewBag.SearchResultCount;
                Services.SetCookie(this.ControllerContext.HttpContext, "NumberOfPages", NumberOfPages2);
                Services.SetCookie(this.ControllerContext.HttpContext, "LowerLimit", LowerLimit2);
                Services.SetCookie(this.ControllerContext.HttpContext, "SearchResutlCount", SearchResultCount2);
                return(PartialView("~/Views/ProductCatWise/PartialCatwiseProductValue.cshtml"));
            }
            if (objModel.ParentCatId == 0)
            {
                var SearchList = ListAllProduct.Where(x => x.ProductName.ToUpper().Contains(objModel.SearchBarText.ToString().ToUpper())).ToList();
                ViewBag.UsersProduct      = SearchList.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
                ViewBag.SearchResultCount = SearchList.Count;
            }
            else
            {
                var SearchList = ListAllProduct.Where(x => x.ProductName.ToUpper().Contains(objModel.SearchBarText.ToString().ToUpper())).ToList();

                var SearchListWithCategory = SearchList.Where(x => x.ParentCatId.Equals(objModel.ParentCatId)).ToList();
                ViewBag.UsersProduct = SearchListWithCategory.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);

                ViewBag.SearchResultCount = SearchListWithCategory.Count;
            }

            #endregion
            if ((ViewBag.SearchResultCount / 10) < (pageindex + 4))
            {
                ViewBag.NumberOfPages = ViewBag.LowerLimit + ((ViewBag.SearchResultCount - 5) - 1);
            }
            else
            {
                ViewBag.NumberOfPages = pageindex + 4;
            }
            ViewBag.ProductsFrom    = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
            ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);

            string NumberOfPages3     = ViewBag.NumberOfPages;
            string LowerLimit3        = ViewBag.LowerLimit;
            string SearchResultCount3 = ViewBag.SearchResultCount;
            Services.SetCookie(this.ControllerContext.HttpContext, "NumberOfPages", NumberOfPages3);
            Services.SetCookie(this.ControllerContext.HttpContext, "LowerLimit", LowerLimit3);
            Services.SetCookie(this.ControllerContext.HttpContext, "SearchResutlCount", SearchResultCount3);
            return(PartialView("~/Views/ProductCatWise/PartialCatwiseProductValue.cshtml"));
        }
コード例 #6
0
        public ActionResult Index(string id)
        {
            long?Id = Convert.ToInt64(CommonFile.Decode(id));

            Services.SetCookie(this.ControllerContext.HttpContext, "ProductCatId", id.ToString());
            ListAllProduct = CommonFile.GetProduct();
            ProductModel objmodel          = new ProductModel();
            var          SearchProductList = new List <ProductModel>();

            if (!CommonFile.IsParentCategory(Id))
            {
                SearchProductList = ListAllProduct.Where(x => x.ProductCatId == Id).ToList();
            }
            else
            {
                SearchProductList = ListAllProduct.Where(x => x.ParentCatId == Id).ToList();
            }
            ViewBag.SearchCatId       = id;
            ViewBag.UsersProduct      = SearchProductList;
            ViewBag.SearchResultCount = SearchProductList.Count;
            var ProductCatList    = CommonFile.GetProductCategory(null);
            var EncodedCategories = new List <DropDownModel>();

            foreach (var item in ProductCatList)
            {
                DropDownModel dropDown = new DropDownModel();
                dropDown.Name         = item.Name;
                dropDown.Id           = item.Id;
                dropDown.EncodedId    = CommonFile.Encode(item.Id.ToString());
                dropDown.CatIdEncoded = CommonFile.Encode(item.ParentCatId.ToString());
                dropDown.ParentCatId  = item.ParentCatId;
                EncodedCategories.Add(dropDown);
            }
            int pageindex = 1;

            ViewBag.UsersProduct      = SearchProductList.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
            ViewBag.LowerLimit        = ((pageindex / 5) * 5) + 1;
            ViewBag.PageIndex         = pageindex;
            ViewBag.ProductsFrom      = ((pageindex - 1) * Constant.NumberOfProducts);
            ViewBag.ToProductsCount   = Enumerable.Count(ViewBag.UsersProduct);
            ViewBag.SearchResultCount = SearchProductList.Count;
            ViewBag.LowerLimit        = 1;
            int nop         = SearchProductList.Count / Constant.NumberOfProducts;
            int remindernop = SearchProductList.Count % 12;

            if (nop < Constant.NumberOfPages)
            {
                if (remindernop > 0)
                {
                    nop = nop + 1;
                }
                ViewBag.NumberOfPages = nop;
            }
            else
            {
                ViewBag.NumberOfPages = Constant.NumberOfPages;
            }
            var ProductCategory = ProductCatList.Where(x => x.Id.Equals(Id));

            ViewBag.ProductCatList = EncodedCategories.Where(x => x.ParentCatId == ProductCategory.Single().ParentCatId);
            if (!CommonFile.IsParentCategory(Id))
            {
                objmodel.ParentCatId = ProductCategory.Single().ParentCatId;
            }
            else
            {
                objmodel.ParentCatId = ProductCategory.Single().Id;
            }
            objmodel.CategoryName = ProductCategory.Single().Name;
            return(View(objmodel));
        }