کلاسی برای کپسوله سازی اطلاعات جستجو و مرتب سازی مقاله های صادر شده توسط متقاضی
Inheritance: Decision.ViewModel.Common.BaseSearchRequest
Exemplo n.º 1
0
 public virtual async Task<ActionResult> ListAjax(ArticleSearchRequest request)
 {
     if (!_referentialTeacherService.CanManageTeacher(request.TeacherId)) return HttpNotFound();
     var viewModel = await _ArticleService.GetPagedListAsync(request);
     if (viewModel.Articles == null || !viewModel.Articles.Any()) return Content("no-more-info");
     return PartialView(MVC.Article.Views._ListAjax, viewModel);
 }
Exemplo n.º 2
0
        public async Task<ArticleListViewModel> GetPagedListAsync(ArticleSearchRequest request)
        {
            var articles =
                _articles.Where(a => a.ApplicantId == request.ApplicantId)
                    .Include(a => a.CreatedBy)
                    .Include(a => a.ModifiedBy)
                    .AsNoTracking()
                    .OrderByDescending(a => a.PublicatedOn)
                    .AsQueryable();

            var selectedArticles = articles.ProjectTo<ArticleViewModel>(_mappingEngine);
            var resultsToSkip = (request.PageIndex - 1)*5;
            var query = await selectedArticles
                .Skip(() => resultsToSkip)
                .Take(5)
                .ToListAsync();

            return new ArticleListViewModel { SearchRequest = request, Articles = query };
        }
Exemplo n.º 3
0
 public virtual async Task<ActionResult> ListAjax(ArticleSearchRequest request)
 {
     var viewModel = await _articleService.GetPagedListAsync(request);
     if (viewModel.Articles == null || !viewModel.Articles.Any()) return Content("no-more-info");
     return PartialView(MVC.Article.Views._ListAjax, viewModel);
 }
Exemplo n.º 4
0
        public async Task<ArticleListViewModel> GetPagedListAsync(ArticleSearchRequest request)
        {
            var Articles =
                _Articles.Where(a => a.TeacherId == request.TeacherId)
                    .Include(a => a.Creator)
                    .Include(a => a.LasModifier)
                    .AsNoTracking()
                    .OrderByDescending(a => a.ArticleDate)
                    .AsQueryable();

            if (request.Term.HasValue())
                Articles = Articles.Where(a => a.Content.Contains(request.Term));

            var selectedArticles = Articles.ProjectTo<ArticleViewModel>(_mappingEngine);


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

            return new ArticleListViewModel { SearchRequest = request, Articles = query };
        }