예제 #1
0
        public async Task <IActionResult> Index()
        {
            var anCollection = await _anAssociationExtension.GetAllIncludingAsyn(x => x.User);

            var anVmCollection = new List <AnAssociationVM>();

            foreach (var an in anCollection)
            {
                var anVM = new AnAssociationVM(an);
                anVmCollection.Add(anVM);
            }

            var pageSize          = 10;
            var pageIndex         = 1;
            var anAssociationList = anVmCollection.OrderBy(x => x.Name).FirstOrDefault();

            //处理分页

            var anAssociationCollectionPageList = IQueryableExtensions.ToPaginatedList(anVmCollection.AsQueryable <AnAssociationVM>(), pageIndex, pageSize);
            var anAssociationCollections        = new List <AnAssociationVM>();

            foreach (var anAssociationCollection in anAssociationCollectionPageList)
            {
                anAssociationCollections.Add(anAssociationCollection);
            }

            //提取当前分页关联的分页器实例
            var pageGroup = PagenateGroupRepository.GetItem(anAssociationCollectionPageList, 5, pageIndex);

            ViewBag.PageGroup = pageGroup;

            var listPageParameter = new ListPageParameter()
            {
                PageIndex        = anAssociationCollectionPageList.PageIndex,
                Keyword          = "",
                PageSize         = anAssociationCollectionPageList.PageSize,
                ObjectTypeID     = "",
                ObjectAmount     = anAssociationCollectionPageList.TotalCount,
                SortDesc         = "Default",
                SortProperty     = "UserName",
                PageAmount       = 0,
                SelectedObjectID = ""
            };

            ViewBag.PageParameter = listPageParameter;
            return(View("~/Views/GroupOrganization/AnAssociation/Index.cshtml", anAssociationCollections));
        }