Exemple #1
0
        private async Task <AchievementCategoryListVM> GetElementsAsync(int?page, string keyword)
        {
            var vm = new AchievementCategoryListVM()
            {
                Keyword   = keyword,
                PageIndex = page ?? 1,
                PageSize  = SettingsManager.Article.PageSize
            };
            var query = _db.AchievementCategories.AsQueryable();

            if (!string.IsNullOrEmpty(keyword))
            {
                query = query.Where(d => d.Title.Contains(keyword));
            }

            var list = await query.OrderByDescending(d => d.Importance)
                       .Skip((vm.PageIndex - 1) * vm.PageSize).Take(vm.PageSize).ProjectTo <AchievementCategoryVM>().ToListAsync();

            //_categoryServices.GetPagedElements(vm.PageIndex-1, vm.PageSize, vm.Keyword, out totalCount);

            vm.TotalCount = await query.CountAsync();

            vm.Categories = new StaticPagedList <AchievementCategoryVM>(list, vm.PageIndex, vm.PageSize, vm.TotalCount);;
            return(vm);
        }
Exemple #2
0
        // GET: Admin/AchievementCategory

        #region 科研成果分类

        public async Task <ActionResult> Index(int?page, string keyword)
        {
            AchievementCategoryListVM categoryListVM = await GetElementsAsync(page, keyword);

            ViewBag.PageSizes = new SelectList(Site.PageSizes());
            return(View(categoryListVM));
        }