کلاسی برای کپسوله سازی اطلاعات جستجو و مرتب سازی مقاله های صادر شده توسط متقاضی
Inheritance: Decision.ViewModel.Common.BaseSearchRequest
Example #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);
 }
Example #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 };
        }
Example #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);
 }
Example #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 };
        }