コード例 #1
0
        //Liệt kê tất cả product với categoryID
        public ActionResult ProductWithCategoryID(long categoryID, int pageIndex, int pageSize = 2)
        {
            var category = new ProductCateogryDao().ViewDetail(categoryID);

            ViewBag.ProductCategory = category;
            int totalRecord = 0;
            var model       = new ProductDao().ListByCategoryId(categoryID, ref totalRecord, pageIndex, pageSize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = pageIndex;
            //maxPage cho nút ở class pagination
            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((decimal)totalRecord / pageSize);
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = pageIndex + 1;
            ViewBag.Prev      = pageIndex - 1;

            return(View(model));
        }
コード例 #2
0
        public PartialViewResult ProductCategory()
        {
            var model = new ProductCateogryDao().ListAll();

            return(PartialView(model));
        }
コード例 #3
0
        public void SetViewBag(long?selectedId = null)
        {
            var dao = new ProductCateogryDao();

            ViewBag.CategoryID = new SelectList(dao.ListAll(), "ID", "Name", selectedId);
        }