Пример #1
0
        // GET: Admin/Product
        public ActionResult Index(int?page, int?size, bool?loadPage, string searchName)
        {
            int  PageNumber = page ?? 1;
            int  PageSize   = size ?? 10;
            bool LoadPage   = loadPage ?? false;

            ViewBag.PageSize           = PageSize;
            ViewBag.LoadPage           = LoadPage;
            ViewBag.SearchName         = string.IsNullOrEmpty(searchName) ? "" : searchName;
            ViewBag.lstSupplier        = supplierBLL.LoadOption();
            ViewBag.lstProductCategory = productCategoryBLL.LoadOption();
            List <Product> model = null;

            if (loadPage == true || Session["SS_LoadProduct"] == null)
            {
                LoadPage                  = false;
                ViewBag.LoadPage          = LoadPage;
                model                     = productBLL.GetAll();
                Session["SS_LoadProduct"] = model;
            }
            else
            {
                model = (List <Product>)Session["SS_LoadProduct"];
            }
            if (!string.IsNullOrEmpty(searchName))
            {
                model = model.Where(x => (x.Name.ToLower().Contains(searchName.ToLower()))).ToList();
            }
            ViewBag.Total = model.Count;
            ViewBag.Page  = PageNumber;
            return(View(model.ToPagedList(PageNumber, PageSize)));
        }