public virtual async Task<ActionResult> ListAjax(ArticleEvaluationSearchRequest request)
        {
            if (!_referentialTeacherService.CanManageTeacher(request.TeacherId)) return HttpNotFound();
            var viewModel =
              await
                  _evaluationService.GetPagedList(request);
            if (viewModel.ArticleEvaluations == null || !viewModel.ArticleEvaluations.Any()) return Content("no-more-info");

            return PartialView(MVC.ArticleEvaluation.Views._ListAjax, viewModel);
        }
예제 #2
0
        public async Task<ArticleEvaluationListViewModel> GetPagedList(ArticleEvaluationSearchRequest request)
        {
            var evaluations = _ArticleEvaluations.AsNoTracking().Include(a => a.Creator)
                .Include(a => a.Evaluator).Where(a=>a.ArticleId==request.ArticleId);

            var result =
                evaluations.OrderByDescending(a => a.EvaluationDate)
                    .ThenByDescending(a => a.CreateDate)
                    .Skip((request.PageIndex - 1)*10)
                    .Take(10)
                    .ProjectTo<ArticleEvaluationViewModel>(_mappingEngine);
            return new ArticleEvaluationListViewModel
            {
                Request = request,
                ArticleEvaluations = await result.ToListAsync()
            };
        }