Ejemplo n.º 1
0
        public ActionResult ProductDetail(PageFilterModel paging)
        {
            if (Session["PageFilterModel"] != null)
            {
                paging = (PageFilterModel)Session["PageFilterModel"];
            }

            ProductDataContext  db = new ProductDataContext();
            List <ProductModel> lloProductModel = new List <ProductModel>();

            try
            {
                int totalrecord = 0;
                var categoryobj = db.SP_SELECTProduct(paging.PageNo, paging.PageSize);
                foreach (var item in categoryobj)
                {
                    totalrecord = item.TotalRow ?? 0;
                    lloProductModel.Add(new ProductModel {
                        ProductID = item.ProductId, ProductName = item.ProductName, CategoryID = item.CategoryId, CategoryName = item.CategoryName
                    });
                }
                int totalPages_pre = (totalrecord / 10);
                paging.totalpage   = (totalrecord % 10) == 0 ? totalPages_pre : totalPages_pre + 1;
                paging.totalRecord = totalrecord;
            }
            catch (Exception)
            {
                throw;
            }
            ViewBag.paging = paging;
            return(View(lloProductModel));
        }