예제 #1
0
        public virtual async Task <ActionResult> ListAjax(QuestionSearchRequest request)
        {
            var viewModel = await _questionService.GetPagedListAsync(request);

            if (viewModel.Questions == null || !viewModel.Questions.Any())
            {
                return(Content("no-more-info"));
            }
            return(PartialView(MVC.Question.Views._ListAjax, viewModel));
        }
예제 #2
0
        public async Task<QuestionListViewModel> GetPagedListAsync(QuestionSearchRequest request)
        {
            var questions = _questions.AsNoTracking().Include(a => a.CreatedBy)
                .Include(a => a.ModifiedBy).OrderByDescending(a => a.CreatedOn).AsQueryable();


            var query = await questions.ProjectTo<QuestionViewModel>(_mappingEngine)
                .Skip((request.PageIndex - 1) * 10)
                .Take(10).ToListAsync();

            return new QuestionListViewModel { SearchRequest = request, Questions = query };
        }
예제 #3
0
 public QuestionSearch(QuestionSearchRequest request)
 {
     if (request != null)
     {
         CourseId     = request.CourseId;
         QuestionIds  = request.QuestionIds;
         Keyword      = request.Keyword;
         QuestionType = request.QuestionType;
         Status       = request.Status;
         PageIndex    = request.PageIndex;
         PageSize     = request.PageSize;
     }
 }
예제 #4
0
        public async Task <QuestionListViewModel> GetPagedListAsync(QuestionSearchRequest request)
        {
            var questions = _questions.AsNoTracking().Include(a => a.CreatedBy)
                            .Include(a => a.ModifiedBy).OrderByDescending(a => a.CreatedOn).AsQueryable();


            var query = await questions.ProjectTo <QuestionViewModel>(_mappingEngine)
                        .Skip((request.PageIndex - 1) * 10)
                        .Take(10).ToListAsync();

            return(new QuestionListViewModel {
                SearchRequest = request, Questions = query
            });
        }
예제 #5
0
        public IActionResult Search(QuestionSearcherViewModel searcher)
        {
            QuestionSearchRequest request = new QuestionSearchRequest
            {
                CourseId     = searcher.CourseId,
                Keyword      = searcher.Keyword,
                PageIndex    = searcher.PageIndex,
                PageSize     = searcher.PageSize,
                QuestionIds  = searcher.QuestionIds.SplitToLongArray(),
                QuestionType = searcher.QuestionType,
                Status       = searcher.Status
            };

            var result = service.Search(request);

            return(Ok(result));
        }
예제 #6
0
 public virtual async Task<ActionResult> ListAjax(QuestionSearchRequest request)
 {
     var viewModel = await _questionService.GetPagedListAsync(request);
     if (viewModel.Questions == null || !viewModel.Questions.Any()) return Content("no-more-info");
     return PartialView(MVC.Question.Views._ListAjax, viewModel);
 }
예제 #7
0
        /// <summary>
        /// 搜索题目信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public PagerModel <Questions> Search(QuestionSearchRequest request)
        {
            QuestionSearch search = new QuestionSearch(request);

            return(search.Search());
        }