public virtual async Task <ActionResult> ListAjax(EducationalBackgroundSearchRequest request) { var viewModel = await _educationalBackgroundService.GetPagedListAsync(request); if (viewModel.EducationalBackgrounds == null || !viewModel.EducationalBackgrounds.Any()) { return(Content("no-more-info")); } return(PartialView(MVC.EducationalBackground.Views._ListAjax, viewModel)); }
public async Task <EducationalBackgroundListViewModel> GetPagedListAsync(EducationalBackgroundSearchRequest request) { var educationalBackgrounds = _educationalBackgrounds.Where(a => a.ApplicantId == request.ApplicantId) .Include(a => a.CreatedBy) .Include(a => a.ModifiedBy) .AsNoTracking() .OrderByDescending(a => a.CreatedOn) .AsQueryable(); var selectedEducationalBackgrounds = educationalBackgrounds.ProjectTo <EducationalBackgroundViewModel>(_mappingEngine); var resultToSkip = (request.PageIndex - 1) * 10; var query = await selectedEducationalBackgrounds .Skip(() => resultToSkip) .Take(10).ToListAsync(); return(new EducationalBackgroundListViewModel { SearchRequest = request, EducationalBackgrounds = query }); }