Ejemplo n.º 1
0
 public virtual async Task<ActionResult> ListAjax(TrainingCourseSearchRequest request)
 {
     var viewModel = await _trainingCourseService.GetPagedListAsync(request);
     if (viewModel.TrainingCourses == null || !viewModel.TrainingCourses.Any())
         return Content("no-more-info");
     return PartialView(MVC.TrainingCourse.Views._ListAjax, viewModel);
 }
Ejemplo n.º 2
0
        public async  Task<TrainingCourseListViewModel> GetPagedListAsync(TrainingCourseSearchRequest request)
        {
            var courses =
                _courses.AsNoTracking()
                    .Where(a => a.TrainingCenterId == request.TrainingCenterId)
                    .Include(a => a.Creator)
                    .Include(a => a.LasModifier)
                    .OrderBy(a => a.CreateDate)
                    .AsQueryable();

            if (request.Term.HasValue())
                courses = courses.Where(a => a.CourseCode.Contains(request.Term));

            var result = courses.ProjectTo<TrainingCourseViewModel>(_mappingEngine);

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

            return new TrainingCourseListViewModel { SearchRequest = request, TrainingCourses = query };
        }