コード例 #1
0
        public ActionResult AdminList(int page)
        {
            var model = new AudioBookListViewModel
            {
                AudioBooks = _context.Books
                             .OrderBy(m => m.Id)
                             .Skip((page - 1) * pageSize)
                             .Take(pageSize),
                PagingInfo = new PageInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = _context.Books.Count()
                }
            };

            return(View("AdminList", model));
        }
コード例 #2
0
        public ViewResult Index(string category, int page)
        {
            var model = new AudioBookListViewModel
            {
                AudioBooks = _context.Books.Where(p => category == null || p.Category == category)
                             .OrderBy(m => m.Id)
                             .Skip((page - 1) * pageSize)
                             .Take(pageSize),
                PagingInfo = new PageInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = _context.Movies.Count()
                },
                CurrentCategory = category
            };

            return(View("BookList", model));
        }