コード例 #1
0
ファイル: TitleService.cs プロジェクト: raminmjj/Decision
        public async Task<TitleListViewModel> GetPagedList(TitleSearchRequest request)
        {
            var titles = _titles.AsNoTracking().Include(a => a.Creator).Include(a => a.LasModifier).OrderByDescending(a => a.CreateDate).AsQueryable();

            if (request.Name.HasValue())
                titles = titles.Where(a => a.Name.Contains(request.Name));
            if ((int)request.Type != 0)
                titles = titles.Where(a => a.Type == request.Type);
            if ((int)request.Category != 0 && request.Type==TitleType.CourseContent)
                titles = titles.Where(a => a.Category == request.Category);

            var selectedTitles = titles.ProjectTo<TitleViewModel>(_mappingEngine);

            var query = await selectedTitles
                .Skip((request.PageIndex - 1)*10)
                .Take(10)
                .ToListAsync();

            return new TitleListViewModel { Request = request, Titles = query };
        }
コード例 #2
0
ファイル: TitleController.cs プロジェクト: raminmjj/Decision
 public virtual async Task<ActionResult> ListAjax(TitleSearchRequest request)
 {
     var viewModel = await _titleService.GetPagedList(request);
     if (viewModel.Titles == null || !viewModel.Titles.Any()) return Content("no-more-info");
     return PartialView(MVC.Title.Views._ListAjax, viewModel);
 }