public ActionResult Next()
        {
            HeaderPartialModel objModel = new HeaderPartialModel();

            objModel.UserName   = "";
            objModel.UserId     = 0;
            objModel.ProfileImg = "";
            return(PartialView("~/Views/Shared/_Header.cshtml", objModel));
        }
        public PartialViewResult HeaderValue()
        {
            HeaderPartialModel    objModel      = new HeaderPartialModel();
            LoginModel            MdUser        = Services.GetLoginUser(this.ControllerContext.HttpContext, _JwtTokenManager);
            List <AddToCartModel> ListAddToCart = Services.GetMyCart(this.ControllerContext.HttpContext, _JwtTokenManager);

            if (MdUser.Id != 0)
            {
                objModel.UserName      = MdUser.Name;
                objModel.UserId        = Convert.ToInt64(MdUser.Id);
                objModel.ProfileImg    = MdUser.ProfileImg;
                objModel.CartItemCount = ListAddToCart.Count();
            }
            else
            {
            }
            return(PartialView("~/Views/Shared/_Header.cshtml", objModel));
        }
        public ActionResult ChangePassword(LoginModel ObjModel)
        {
            if (ModelState.IsValid)
            {
                LoginModel MdUser = Services.GetLoginUser(this.ControllerContext.HttpContext, _JwtTokenManager);
                if (MdUser.Id != 0)
                {
                    ObjModel.Id = Convert.ToInt64(MdUser.Id);
                }
                string PasswordEncripy  = CommonFile.EncodePasswordMd5(ObjModel.NewPassword);
                string PasswordEncripy2 = CommonFile.EncodePasswordMd5(ObjModel.Password);
                ObjModel.ConfirmNewPassword = PasswordEncripy;
                ObjModel.NewPassword        = PasswordEncripy;
                ObjModel.Password           = PasswordEncripy2;
                var           _request     = JsonConvert.SerializeObject(ObjModel);
                ResponseModel ObjResponse  = CommonFile.GetApiResponse(Constant.ApiChangePassword, _request);
                ResponseModel ObjResponse1 = JsonConvert.DeserializeObject <ResponseModel>(ObjResponse.Response);


                if (String.IsNullOrWhiteSpace(ObjResponse.Response))
                {
                    return(View("Index", ObjModel));
                }
                if (ObjResponse1.Response.Equals("Wrong Password"))
                {
                    ViewBag.ResponseMessage = "Your Current Password is Wrong";
                    return(View("Index", ObjModel));
                }
                else
                {
                    ViewBag.ResponseMessage = "Your Password has been changed Please Login ";
                    Services.RemoveCookie(this.ControllerContext.HttpContext, "usr");
                    HeaderPartialModel objModel = new HeaderPartialModel();
                    objModel.UserName   = "";
                    objModel.UserId     = 0;
                    objModel.ProfileImg = "";
                    IsChangePassword    = true;
                    return(View("Index", ObjModel));
                    // return RedirectToAction("Index","Login");
                }
            }

            return(View("Index", ObjModel));
        }
Пример #4
0
        public PartialViewResult HeaderValue(HeaderPartialModel objmodel1)
        {
            HeaderPartialModel    objModel      = new HeaderPartialModel();
            LoginModel            MdUser        = Services.GetLoginWebUser(this.ControllerContext.HttpContext, _JwtTokenManager);
            List <AddToCartModel> ListAddToCart = Services.GetMyCart(this.ControllerContext.HttpContext, _JwtTokenManager);

            objModel.UserName      = MdUser.Name;
            objModel.UserId        = Convert.ToInt64(MdUser.Id);
            objModel.ProfileImg    = MdUser.ProfileImg;
            objModel.CartItemCount = ListAddToCart.Count();
            objModel.RegisterType  = MdUser.RegisterType;

            ViewBag.AddToCart = ListAddToCart;

            ViewBag.TotalAmount = GetTotalAmount(ListAddToCart);

            var parentcategories = CommonFile.GetProductCategory(0);

            ViewBag.ParentCategories = new SelectList(parentcategories, "Id", "Name");
            objModel.ParentCatId     = objmodel1.ParentCatId;
            ViewBag.ProductCatList   = CommonFile.GetProductCategory(null);
            return(PartialView("~/Views/Shared/_WebsiteHeader.cshtml", objModel));
        }
        public PartialViewResult PreviousPages(long id)
        {
            int pageindex = (int)id;

            //if (pageindex != 0)
            //{
            ViewBag.PageIndex = pageindex;
            HeaderPartialModel objModel = new HeaderPartialModel();

            ViewBag.LowerLimit = id - 4;
            #region  For binding products in next page


            if (String.IsNullOrWhiteSpace(objModel.SearchBarText))
            {
                if (objModel.ParentCatId == 0)
                {
                    ViewBag.UsersProduct      = ListAllProduct.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
                    ViewBag.SearchResultCount = ListAllProduct.Count;
                    if ((ViewBag.SearchResultCount / 10) < (pageindex + 4))
                    {
                        ViewBag.NumberOfPages = ViewBag.LowerLimit * 5;
                    }
                    else
                    {
                        ViewBag.NumberOfPages = pageindex;
                    }
                    ViewBag.ProductsFrom    = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
                    ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);

                    Services.SetCookie(this.ControllerContext.HttpContext, "NumberOfPages", ViewBag.NumberOfPages.ToString());
                    Services.SetCookie(this.ControllerContext.HttpContext, "LowerLimit", ViewBag.LowerLimit.ToString());
                    Services.SetCookie(this.ControllerContext.HttpContext, "SearchResutlCount", ViewBag.SearchResultCount.ToString());
                    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
            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"));
            //}
            //else
            //{

            //}
        }
        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"));
        }
Пример #7
0
        public ActionResult PreviousPages(string Id)
        {
            long? id = Convert.ToInt64(CommonFile.Decode(Id));
            if (id == 0) { id = 1; }
            int pageindex = (int)id;
            ViewBag.PageIndex = pageindex;
            ViewBag.PageNoactive = id;
            HeaderPartialModel objModel = new HeaderPartialModel();
            if (pageindex % 5 == 0)
            {
                if ((pageindex / 5) == 1)
                { ViewBag.LowerLimit = ((pageindex / 5)); }
                else
                {
                    ViewBag.LowerLimit = pageindex - 5;
                }
            }
            else
            {
                ViewBag.LowerLimit = ((pageindex / 5) * 5) + 1;
            }

            #region  For binding products in next page

            // ListAllProduct = CommonFile.GetProduct();
            if (String.IsNullOrWhiteSpace(objModel.SearchBarText))
            {

                if (objModel.ParentCatId == 0)
                {
                    ViewBag.UsersProduct = ListAllProduct.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
                    ViewBag.SearchResultCount = ListAllProduct.Count;
                    if ((ViewBag.SearchResultCount / 10) < (pageindex + 4))
                    {
                        ViewBag.NumberOfPages = ViewBag.LowerLimit * 5;
                    }
                    else
                    {
                        ViewBag.NumberOfPages = ViewBag.LowerLimit + 4;
                    }
                    ViewBag.ProductsFrom = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
                    ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
                    return View("SearchBar");
                }
                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);
                return View("SearchBar");
            }
            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
            ViewBag.ProductsFrom = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
            ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
            return View("SearchBar");
        }
Пример #8
0
        public ActionResult MorePages(string Id)
        {
            long? id = Convert.ToInt64(CommonFile.Decode(Id));
            int pageindex = (int)id;
            ViewBag.PageIndex = pageindex;
            ViewBag.PageNoactive = id;
            HeaderPartialModel objModel = new HeaderPartialModel();
            //HeaderPartialModel objModel = new HeaderPartialModel();
            string SearchCookieValue = Services.GetCookie(this.HttpContext, "SearchBarCookie").Value;
            dynamic _data = SearchCookieValue;
            var json = JsonConvert.DeserializeObject<Dictionary<string, object>>(_data);
            if (json.ContainsKey("ParentCatId"))
            {
                string ParentCatId = json["ParentCatId"].ToString();
                string SearchBarText = json["SearchBarText"].ToString();
                objModel.ParentCatId = long.Parse(ParentCatId);
                objModel.SearchBarText = SearchBarText;
            }
            if (pageindex % 5 == 0)
            {
                ViewBag.LowerLimit = ((pageindex / 5));
            }
            else
            {
                ViewBag.LowerLimit = ((pageindex / 5) * 5) + 1;
            }
            //ViewBag.NumberOfPages = pageindex+4;
            #region  For binding products in next page

            //ListAllProduct = CommonFile.GetProduct();
            if (String.IsNullOrWhiteSpace(objModel.SearchBarText))
            {

                if (objModel.ParentCatId == 0)
                {
                    ViewBag.UsersProduct = ListAllProduct.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
                    ViewBag.SearchResultCount = ListAllProduct.Count;
                    if ((ViewBag.SearchResultCount / Constant.NumberOfProducts) < (pageindex + 4))
                    {
                        ViewBag.NumberOfPages = (ViewBag.SearchResultCount / Constant.NumberOfProducts);
                    }
                    else
                    {
                        ViewBag.NumberOfPages = ViewBag.LowerLimit + 4;
                    }
                    ViewBag.ProductsFrom = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
                    ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
                    return View("SearchBar");
                }
                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 / Constant.NumberOfProducts) < (pageindex + 4))
                {
                    if ((ViewBag.SearhResultCount % Constant.NumberOfProducts) != 0) { ViewBag.NumberOfPages = (ViewBag.SearchResultCount / Constant.NumberOfProducts) + 1; }
                    else { ViewBag.NumberOfPages = (ViewBag.SearchResultCount / Constant.NumberOfProducts); }
                }
                else
                {
                    ViewBag.NumberOfPages = pageindex + 4;
                }
                ViewBag.ProductsFrom = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
                ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
                return View("SearchBar");
            }
            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 / Constant.NumberOfProducts) < (pageindex + 4))
            {
                if ((ViewBag.SearhResultCount % Constant.NumberOfProducts) != 0) { ViewBag.NumberOfPages = (ViewBag.SearchResultCount / Constant.NumberOfProducts) + 1; }
                else { ViewBag.NumberOfPages = (ViewBag.SearchResultCount / Constant.NumberOfProducts); }
            }
            else
            {
                ViewBag.NumberOfPages = pageindex + 4;
            }
            ViewBag.ProductsFrom = ((pageindex - 1) * Constant.NumberOfProducts) + 1;
            ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
            return View("SearchBar");
        }
Пример #9
0
        public ActionResult SearchBar(HeaderPartialModel objModel)
        {
            ViewBag.LowerLimit = 1;
            ViewBag.PageIndex = 1;
            ViewBag.ProductsFrom = 0;
            ViewBag.LowerLimit = 1;
            ViewBag.PageNoactive = 1;
            if (String.IsNullOrWhiteSpace(objModel.SearchBarText))
            {
                if (objModel.ParentCatId == 0)
                {
                    ViewBag.UsersProduct = ListAllProduct.Take(Constant.NumberOfProducts);
                    ViewBag.ProductsFrom = 1;
                    ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
                    ViewBag.SearchResultCount = ListAllProduct.Count;
                    ViewBag.NumberOfPages = 5;
                    var jsonString1 = "{\"ParentCatId\":\"" + objModel.ParentCatId + "\",\"SearchBarText\":\"" + objModel.SearchBarText + "\"}";
                    Services.SetCookie(this.ControllerContext.HttpContext, "SearchBarCookie", jsonString1.ToString());
                    return View();
                }
                var SearchListWithCategory = ListAllProduct.Where(x => x.ParentCatId.Equals(objModel.ParentCatId)).ToList();
                ViewBag.UsersProduct = SearchListWithCategory.Take(Constant.NumberOfProducts);
                ViewBag.SearchResultCount = SearchListWithCategory.Count;
                ViewBag.NumberOfPages = 5;
                var jsonString2 = "{\"ParentCatId\":\"" + objModel.ParentCatId + "\",\"SearchBarText\":\"" + objModel.SearchBarText + "\"}";
                Services.SetCookie(this.ControllerContext.HttpContext, "SearchBarCookie", jsonString2.ToString());
                return View();
            }
            if (objModel.ParentCatId == 0)
            {
                var SearchList = ListAllProduct.Where(x => x.ProductName.ToUpper().Contains(objModel.SearchBarText.ToString().ToUpper())).ToList();
                ViewBag.ProductsFrom = 1;
                ViewBag.UsersProduct = SearchList.Take(Constant.NumberOfProducts);
                ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);

                if (SearchList.Count == 0) { ViewBag.NoResultFound = "No Result Found"; }
                else { ViewBag.NoResultFound = ""; }
                //ViewBag.PopularProducts = CommonFile.GetPopularProduct();
                ViewBag.SearchResultCount = SearchList.Count;
                if ((SearchList.Count / Constant.NumberOfProducts) < 5)
                {
                    if (SearchList.Count % Constant.NumberOfProducts == 0) { ViewBag.NumberOfPages = SearchList.Count / Constant.NumberOfProducts; }
                    else { ViewBag.NumberOfPages = (SearchList.Count / Constant.NumberOfProducts) + 1; }
                }
                else
                    ViewBag.NumberOfPages = 5;
            }
            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.Take(Constant.NumberOfProducts);
                ViewBag.ToProductsCount = Enumerable.Count(ViewBag.UsersProduct);
                //ViewBag.PopularProducts = CommonFile.GetPopularProduct();
                ViewBag.SearchResultCount = SearchListWithCategory.Count;
                ViewBag.NumberOfPages = 5;
            }
            var jsonString = "{\"ParentCatId\":\"" + objModel.ParentCatId + "\",\"SearchBarText\":\"" + objModel.SearchBarText + "\"}";
            Services.SetCookie(this.ControllerContext.HttpContext, "SearchBarCookie", jsonString.ToString());
            int pageindex = ViewBag.PageIndex;
            ViewBag.PageIndex = pageindex;
            var SearchList1 = ListAllProduct.Where(x => x.ProductName.ToUpper().Contains(objModel.SearchBarText.ToString().ToUpper())).ToList();
            return View();
        }