public void List(int pageIndex) { PropertyBag["params"] = new { PageIndex = pageIndex }; int _totalNums = 0, _pageSize = 12; if (pageIndex < 1) { pageIndex = 1; } string _conAttr = "1 = 1"; IList <BulletinBoard> _bulletinBoardList = _bulletinBoardService.PaginatedBulletinBoard(pageIndex, _pageSize, "ID", _conAttr, ref _totalNums); PropertyBag["bulletinBoardList"] = _bulletinBoardList; string uri = "BulletinBoardList.do?pageIndex={0}"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["ltlShowPager"] = ltlShowPager; }
public ActionResult ActiveApplies(int id, int?page) { var applies = siteService.GetApplies(id).OrderBy(m => m.Backup).ToList(); var model = new Paginated <Apply>(applies, page ?? 1, 10); return(View(model)); }
//分页查询 public async Task <List <TEntity> > Query(Paginated paginated) { var count = _context.Set <TEntity>().Count(); paginated.records = count; return(await(PaginatedList <TEntity> .CreateAsync(_context.Set <TEntity>().AsNoTracking(), paginated.page, paginated.limit))); }
public ActionResult Tags(int?page) { var tags = siteService.GetTags().ToList(); var model = new Paginated <ActiveTag>(tags, page ?? 1, 60); return(View(model)); }
public void XHrList(int employeeID, int stID, string examDate, int pageIndex) { int _totalNums = 0, _pageSize = 12; string _conAttr = "1 = 1"; if (employeeID > 0) { _conAttr += " AND EmployeeID =" + employeeID; } if (stID > 0) { _conAttr += " AND STID =" + stID; } DateTime _examDate = DateTime.Today; if (!string.IsNullOrEmpty(examDate) && DateTime.TryParse(examDate, out _examDate)) { _conAttr += " AND DATEDIFF(day,ExamDate,'" + _examDate.ToString("yyyy-MM-dd") + "') = 0"; } IList <ReportCard> _reportCardList = _reportCardService.PaginatedReportCard(pageIndex, _pageSize, "ID", _conAttr, ref _totalNums); PropertyBag["reportCardList"] = _reportCardList; string uri = "javascript:jsPaginated(" + employeeID + "," + stID + ",'" + examDate + "',{0});"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["ltlShowPager"] = ltlShowPager; CancelLayout(); }
public void List(int pageIndex) { PropertyBag["params"] = new { PageIndex = pageIndex }; int _totalNums = 0, _pageSize = 12; if (pageIndex < 1) { pageIndex = 1; } string _conAttr = "1 = 1"; IList <PhotoGraph> _photoGraphList = _photoGraphService.PaginatedPhotoGraph(pageIndex, _pageSize, "SortNum", _conAttr, ref _totalNums); PropertyBag["photoGraphList"] = _photoGraphList; string uri = "List.do?pageIndex={0}"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["ltlShowPager"] = ltlShowPager; }
public void OnGet(int?current) { Items = Context.People .OrderBy(x => x.Name) .OrderBy(x => x.Id) .ToPaginated(current ?? 1, 2); }
public ActionResult Index(int?page, int id) { var blogs = blogService.GetBlogs(id).ToList(); var pblogs = new Paginated <Blog>(blogs, page ?? 1, 10); return(View(pblogs)); }
public ActionResult Search(int?page, string k) { IEnumerable <Movie> list = null; int total = 0; string word = ""; if (!string.IsNullOrEmpty(k)) { var search = new SearchHelper(); list = search.Search(k, page, out total, out word); ViewBag.PageTitle = word; sites.SaveKeyword(k); } var pBlogs = new Paginated <Movie>(list.AsQueryable(), page ?? 1, 24, total); var model = new BlogsViewModel(pBlogs, null, null, null); if (page.HasValue) { ViewBag.PageTitle += "_第" + page + "页"; } return(View("~/Views/Movie/Index.cshtml", model)); }
public void TestPaginatedWithIQuerable() { int pageNumber = 1; int pageSize = 2; Paginated <People> st = Database.People.ToPaginated(pageNumber, pageSize); PaginatedMetaData metaData = st.ToPaginatedMetaData(); Assert.IsInstanceOfType(st, typeof(Paginated <People>)); Assert.IsInstanceOfType(st, typeof(IPaginated)); Assert.IsInstanceOfType(st, typeof(IPaginated <People>)); Assert.IsInstanceOfType(st, typeof(IList)); Assert.IsInstanceOfType(st, typeof(IList <People>)); Assert.IsInstanceOfType(st, typeof(List <People>)); Assert.IsInstanceOfType(st, typeof(PaginatedBase <People>)); Assert.IsInstanceOfType(metaData, typeof(PaginatedMetaData)); Assert.AreEqual(metaData.FirstItemOnPage, 1); Assert.IsTrue(metaData.HasNextPage); Assert.IsFalse(metaData.HasPreviousPage); Assert.IsTrue(metaData.IsFirstPage); Assert.IsFalse(metaData.IsLastPage); Assert.AreEqual(metaData.LastItemOnPage, 2); Assert.AreEqual(metaData.MaximumPageNumbersToDisplay, 8); Assert.AreEqual(metaData.PageCount, 5); Assert.AreEqual(metaData.Pages.Count, 5); Assert.AreEqual(metaData.PageNumber, 1); Assert.AreEqual(metaData.PageSize, 2); Assert.AreEqual(metaData.TotalItemCount, st.TotalItemCount); }
// // GET: /Admin/Settings/ public ActionResult TagsList(int?page) { var tags = siteService.GetTags().Where(m => m.IsPublic == "Y").ToList(); var model = new Paginated <ActiveTag>(tags, page ?? 1, 10); return(View(model)); }
public void DynamicCriteriaExtensions_ApplyDynamicPaginatedCriteria_ReturnPaginatedFilteredResult() { // arrange DbHelper.CleanBlog(_dbContext); DbHelper.SeedBulkBlogs(_dbContext); var filteredList = _dbContext.Blogs .OrderByDescending(o => o.Id) .Where(q => q.Id > 10) .ToList(); var expected = new Paginated <Blog>(filteredList.Skip(3).Take(3).ToList(), filteredList.Count, 2, 3); // act var criteria = new DynamicPaginatedCriteria { Sorts = "Id desc", FilterClause = "Id > @0", FilterParameters = new object[] { 10 }, CurrentPage = 2, PageSize = 3 }; var actual = _dbContext.Blogs.ToPaginated(criteria); // assert Assert.Equal(expected, actual, new PaginatedEqualityComparer <Blog>()); }
public async Task <Paginated <Customer> > GetPageAsync <TOrder>(Expression <Func <Customer, TOrder> > order, int pageNumber, int pageSize, CancellationToken ct = default) { var itemCount = await _dbSet.CountAsync(); int pagesCount = 0; ICollection <Customer> pageItems = null; if (itemCount != 0 && pageSize > 0) { pagesCount = (itemCount / pageSize) + ((itemCount % pageSize == 0) ? 0 : 1); pageItems = await GetLimitAsync(order, pageSize, ((pageNumber - 1) < 0 ? 0 : (pageNumber - 1)) * pageSize, ct); } Paginated <Customer> paginatedResult = new Paginated <Customer> { ItemsCount = itemCount, PagesCount = pagesCount, PageNumber = pageNumber, PageItems = pageItems }; return(paginatedResult); }
public void List(int catalogID, int pageIndex) { pageIndex = pageIndex <= 0 ? 1 : pageIndex; PropertyBag["params"] = new { CatalogID = catalogID, PageIndex = pageIndex }; int _totalNums = 0, _pageSize = 12; IList <Catalog> _catalogList = _catalogService.PaginatedCatalog(1, 120, "ID", "ModuleCn = 'Article'", ref _totalNums); PropertyBag["catalogList"] = _catalogList; string _conAttr = "catalogID = " + catalogID + ""; IList <Article> _artilceList = _articleService.PaginatedArticle(pageIndex, _pageSize, "ID", _conAttr, ref _totalNums); string uri = "List.do?catalogID=" + catalogID + "&pageIndex={0}"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["articleList"] = _artilceList; PropertyBag["ltlShowPager"] = ltlShowPager; }
public ActionResult Notice(int?page) { var blogs = blogService.GetBlogs().Where(m => m.CategoryID == 10 && m.IsPublic == true).ToList(); var pblogs = new Paginated <Blog>(blogs, page ?? 1, 8); return(View(pblogs)); }
public virtual async Task <Paginated <T> > GetPageAsync(Expression <Func <T, bool> > @where, int pageNumber, int pageSize, CancellationToken ct = default) { var itemCount = await CountAsync(where); int pagesCount = 0; ICollection <T> pageItems = null; if (itemCount != 0 && pageSize > 0) { pagesCount = (itemCount / pageSize) + ((itemCount % pageSize == 0) ? 0 : 1); pageItems = await GetLimitAsync(where, pageSize, ((pageNumber - 1) < 0 ? 0 : (pageNumber - 1)) * pageSize, ct); } Paginated <T> paginatedResult = new Paginated <T> { ItemsCount = itemCount, PagesCount = pagesCount, PageNumber = pageNumber, PageItems = pageItems }; return(paginatedResult); }
// // GET: /Admin/Links/ public ActionResult Index(int?page) { var links = siteService.GetLinks(); var model = new Paginated <Links>(links, page ?? 1, 20); return(View(model)); }
public void List(string searchName, int pageIndex) { pageIndex = pageIndex <= 0 ? 1 : pageIndex; PropertyBag["params"] = new { PageIndex = pageIndex, SearchName = searchName }; int _totalNums = 0, _pageSize = 10; string _conAttr = "1 = 1"; if (!string.IsNullOrEmpty(searchName)) { _conAttr += " AND trueName LIKE '%" + searchName + "%'"; } IList <ScheNotice> _scheNoticeList = _scheNoticeService.PaginatedScheNotice(pageIndex, _pageSize, "ID", _conAttr, ref _totalNums); PropertyBag["scheNoticeList"] = _scheNoticeList; string uri = "List.do?searchName=" + searchName + "&pageIndex={0}"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["ltlShowPager"] = ltlShowPager; }
public void List(int pageIndex) { PropertyBag["params"] = new { PageIndex = pageIndex }; int _totalNums = 0; int _pageSize = 12; if (pageIndex < 1) { pageIndex = 1; } string _conAttr = "1 = 1"; IList <Message> _messageList = _messageService.PaginatedMessage(pageIndex, _pageSize, "ID", _conAttr, ref _totalNums); PropertyBag["messageList"] = _messageList; string uri = "messageList.do?pageIndex={0}"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["ltlShowPager"] = ltlShowPager; }
// // GET: /Admin/Student/ public ActionResult Index(int?page) { var list = db.GetStudentList().ToList(); var model = new Paginated <Student>(list, page ?? 1, 15); return(View(model)); }
public ActionResult Index(int?page, int?id) { var applies = applyService.GetApplies().OrderByDescending(m => m.DateCreated).ToList(); var papplies = new Paginated <ApplyOnline>(applies, page ?? 1, 25); return(View(papplies)); }
public void List(int pageIndex, int stID = 0) { PropertyBag["params"] = new { STID = stID, PageIndex = pageIndex }; int _totalNums = 0, _pageSize = 12; if (pageIndex < 1) { pageIndex = 1; } IList <SchoolTerm> _schoolTermList = _schoolTermService.PaginatedSchoolTerm(1, 120, "ID", "1 = 1", ref _totalNums); PropertyBag["schoolTermList"] = _schoolTermList; string _conAttr = "1 = 1"; if (stID > 0) { _conAttr += " AND STID = " + stID; } IList <Video> _videoList = _videoService.PaginatedVideo(pageIndex, _pageSize, "SortNum", _conAttr, ref _totalNums); PropertyBag["videoList"] = _videoList; string uri = "List.do?stID=" + stID + "&pageIndex={0}"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["ltlShowPager"] = ltlShowPager; }
public ActionResult VoteList(int?page) { var list = voteService.GetVoteList(); var model = new Paginated <Vote>(list, page ?? 1, 15); return(View(model)); }
public void List(int catalogID, int pageIndex) { Catalog _catalog = _catalogService.GetCatalogByID(catalogID); if (_catalog != null) { int _totalNums = 0; int _pageSize = 20; if (pageIndex < 1) { pageIndex = 1; } string _conAttr = "catalogID = " + catalogID + ""; IList <Article> _articleList = _articleService.PaginatedArticle(pageIndex, _pageSize, "ID", _conAttr, ref _totalNums); string uri = "List.do?catalogID=" + catalogID + "&pageIndex={0}"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["catalog"] = _catalog; PropertyBag["articleList"] = _articleList; PropertyBag["ltlShowPager"] = ltlShowPager; } }
public ActionResult Applies(int?page) { var applies = siteService.GetApplies(User.Identity.Name).ToList(); var model = new Paginated <Apply>(applies, page ?? 1, 10); return(View(model)); }
static void TestIQueryablePaginated(int page, int total = 5) { using (DatabaseContext db = new DatabaseContext()) { var count = db.People.Count(); Paginated <People> listOfQueryable0 = db.People .OrderBy(x => x.Name) .ToPaginated(page, total); Paginated <People> listOfQueryable1 = db.People .OrderBy(x => x.Name) .ToPaginated((page + 1), total); PaginatedMetaData am0 = listOfQueryable0.ToPaginatedMetaData(); PaginatedMetaData am1 = listOfQueryable1.ToPaginatedMetaData(); int[] ap0 = listOfQueryable0.Pages.ToArray(); int[] ap1 = listOfQueryable1.Pages.ToArray(); listOfQueryable0.SetPages(1); int[] ap3 = listOfQueryable0.Pages.ToArray(); listOfQueryable1.SetPages(1); int[] ap4 = listOfQueryable1.Pages.ToArray(); } }
public void XHrList(string searchUserName, int stID, int pageIndex) { PropertyBag["params"] = new { SearchUserName = searchUserName, STID = stID, PageIndex = pageIndex }; pageIndex = pageIndex <= 0 ? 1 : pageIndex; int _totalNums = 0, _pageSize = 12; string _conAttr = "1 = 1"; if (!string.IsNullOrEmpty(searchUserName)) { _conAttr += " AND Employee.Name = '" + searchUserName + "'"; } if (stID > 0) { _conAttr += " AND Registration.STID = " + stID; } IList <Registration> _registrationList = _registrationService.PaginatedRegistration(pageIndex, _pageSize, "ID", _conAttr, ref _totalNums); string uri = "javascript:jsPaginated('" + searchUserName + "'," + stID + ",{0});"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["registrationList"] = _registrationList; PropertyBag["ltlShowPager"] = ltlShowPager; CancelLayout(); }
public async void ShouldReturnOkWithResults() { // Arrange var urls = new List <UrlDto> { new UrlDto { Id = 2, AccessCount = 1, ActualUrl = "https://google.com", ShortenedUrl = "GH65ff" }, new UrlDto { Id = 1, AccessCount = 5, ActualUrl = "https://youtube.com", ShortenedUrl = "3H6Dwe" } }; Paginated <UrlDto> paginatedResults = new Paginated <UrlDto>(urls, 2, 1, 10); UrlServiceMock.Setup(x => x.GetAll(1, 10)).ReturnsAsync(paginatedResults); // Act var result = await UrlControllerToTest.Get(1, 10); // Assert var okResult = Assert.IsType <OkObjectResult>(result); Assert.Same(paginatedResults, okResult.Value); }
//分页排序查询 public async Task <List <TEntity> > Query(string strWhere, Paginated paginated) { paginated.sord = "asc"; bool isAsc = paginated.sord.ToLower() == "asc" ? true : false; //string[] _order = paginated.sidx.Split(','); string[] _order = strWhere.Split(','); MethodCallExpression resultExp = null; var tempData = await Task.FromResult(_context.Set <TEntity>().AsQueryable()); foreach (string item in _order) { string _orderPart = item; _orderPart = Regex.Replace(_orderPart, @"\s+", " "); string[] _orderArry = _orderPart.Split(' '); string _orderField = _orderArry[0]; bool sort = isAsc; if (_orderArry.Length == 2) { isAsc = _orderArry[1].ToUpper() == "ASC" ? true : false; } var parameter = Expression.Parameter(typeof(TEntity), "t"); var property = typeof(TEntity).GetProperty(_orderField); var propertyAccess = Expression.MakeMemberAccess(parameter, property); var orderByExp = Expression.Lambda(propertyAccess, parameter); resultExp = Expression.Call(typeof(Queryable), isAsc ? "OrderBy" : "OrderByDescending", new Type[] { typeof(TEntity), property.PropertyType }, tempData.Expression, Expression.Quote(orderByExp)); } tempData = tempData.Provider.CreateQuery <TEntity>(resultExp); paginated.records = tempData.Count(); tempData = tempData.Skip <TEntity>(paginated.limit * (paginated.page - 1)).Take <TEntity>(paginated.limit).AsQueryable(); return(tempData.ToList()); }
// // GET: /Admin/Vote/ public ActionResult Index(int?page) { var votes = voteService.GetVoteList(); var model = new Paginated <Vote>(votes, page ?? 1, 15); return(View(model)); }