public async Task <IActionResult> Index() { var boCollection = await _PersonExtension.GetAllAsyn(); var boVMCollection = new List <PersonVM>(); foreach (var bo in boCollection) { var boVM = new PersonVM(bo); boVMCollection.Add(boVM); } var pageSize = 10; var pageIndex = 1; var personList = boVMCollection.OrderBy(x => x.Name).FirstOrDefault(); // 处理分页 var personCollectionPageList = IQueryableExtensions.ToPaginatedList(boVMCollection.AsQueryable <PersonVM>(), pageIndex, pageSize); var personCollections = new List <PersonVM>(); foreach (var personCollection in personCollectionPageList) { personCollections.Add(personCollection); } //提取当前分页关联的分页器实例 var pageGroup = PagenateGroupRepository.GetItem <PersonVM>(personCollectionPageList, 3, pageIndex); ViewBag.PageGroup = pageGroup; var listPageParameter = new ListPageParameter() { PageIndex = personCollectionPageList.PageIndex, Keyword = "", PageSize = personCollectionPageList.PageSize, ObjectTypeID = "", ObjectAmount = personCollectionPageList.TotalCount, SortDesc = "Default", SortProperty = "UserName", PageAmount = 0, SelectedObjectID = "" }; ViewBag.PageParameter = listPageParameter; return(View("~/Views/BusinessOrganization/Person/Index.cshtml", personCollections)); }
public async Task <IActionResult> SingAndExchange(int index) { var datas = await _anassociationExtension.GetAll().Include(x => x.Avatar).ToListAsync(); datas = datas.Skip(index * pageSize).Take(pageSize).ToList(); var flag = false; var anAssociations = new List <AnAssociationVM>(); if (datas.Count() == 0) { datas = (await _anassociationExtension.GetAllAsyn()).Take(pageSize).ToList(); flag = true; } foreach (var item in datas) { var anVm = new AnAssociationVM(item) { AnAssociationNum = (await _anassociationAndUserExtension.GetAll().Where(x => x.AnAssociationId == item.ID).ToListAsync()).Count }; anAssociations.Add(anVm); } return(Json(new { Items = anAssociations, ifLastIndex = flag })); }