コード例 #1
0
        protected IQuery <AnswerDTO> CreateQuery(QuestionFilter filter)
        {
            var query = AnswerListQuery;

            query.Filter = filter;
            return(query);
        }
コード例 #2
0
        protected IQuery <QuestionDTO> CreateQuery(QuestionFilter filter)
        {
            var query = QuestionListQuery;

            query.Filter = filter;
            return(query);
        }
コード例 #3
0
        public async Task <IActionResult> GetFilteredList(QuestionFilter filter)
        {
            var result = await _questionBankService.FilteredListAsync(filter);

            var resultDTO = _mapper.Map <IEnumerable <QuestionDTO> >(result.Questions);

            return(Ok(resultDTO));
        }
コード例 #4
0
        public async Task <QuestionResponse> FilteredListAsync(QuestionFilter filter)
        {
            var filteredQuestions = _questionRepository.QueryableData()
                                    .SpecializationFilter(filter.SpecializationID)
                                    .FiledFilter(filter.FiledID);

            return(new QuestionResponse(await filteredQuestions.ToListAsync()));
        }
コード例 #5
0
        public async Task <IActionResult> GetFilteredListPage(QuestionFilter filter, int pageIndex, int pageSize)
        {
            var result = await _questionBankService.FilteredListAsync(filter);

            var resultDTO = _mapper.Map <IEnumerable <QuestionDTO> >(result.Questions);

            var page = new PaginatedResponse <QuestionDTO>(resultDTO, pageIndex, pageSize);

            return(Ok(page.Data));
        }
コード例 #6
0
        public async Task <IEnumerable <QuestionEntity> > GetQuestionsAsync(QuestionFilter filter, CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            var entitiesQuery = ApplyFilter(Entities, filter);
            var result        = await entitiesQuery
                                .Include(t => t.Answers)
                                .ToListAsync(cancellationToken);

            return(result);
        }
コード例 #7
0
        // GET: Questions
        public virtual ActionResult QuestionList(QuestionFilter questionFilter = null)
        {
            var questionList = new QuestionListViewModel
            {
                TaskId = questionFilter.TaskId.Value,
                TaskName = TaskService.GetById(questionFilter.TaskId.Value).Title
            };

            var questions = QuestionService.GetAll(Query.ForQuestion(questionFilter).Include(x => x.Answers())).Decorate<Question, QuestionViewModel>();
            questionList.AddRange(questions);

            return PartialView(MVC.Questions.Views._QuestionList, questionList);
        }
コード例 #8
0
        public async Task <IActionResult> Get([FromBody] QuestionFilter model)
        {
            if (model.LawyerQuestions)
            {
                var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
                var user   = await UserManager.FindByIdAsync(userId);

                model.LawyerId = user.LawyerId;
            }


            var res = QuestionService.Get(model);

            return(Ok(res));
        }
コード例 #9
0
 public IEnumerable<Question> FindQuestions(QuestionSearchCriteria criteria)
 {
     var filter = new QuestionFilter(criteria);
     return filter.Select(Entities.Questions);
     //return criteria.Disciplines != null
     //    ? from question in Entities.Questions
     //      where
     //          question.Title.Contains(criteria.Keyword) &&
     //          question.Disciplines.Any(d => criteria.Disciplines.Contains(d.Id))
     //      orderby question.PostedDate descending
     //      select question
     //    : from question in Entities.Questions
     //      where
     //          question.Title.Contains(criteria.Keyword)
     //      orderby question.PostedDate descending
     //      select question;
 }
コード例 #10
0
        public IEnumerable <Question> FindQuestions(QuestionSearchCriteria criteria)
        {
            var filter = new QuestionFilter(criteria);

            return(filter.Select(Entities.Questions));
            //return criteria.Disciplines != null
            //    ? from question in Entities.Questions
            //      where
            //          question.Title.Contains(criteria.Keyword) &&
            //          question.Disciplines.Any(d => criteria.Disciplines.Contains(d.Id))
            //      orderby question.PostedDate descending
            //      select question
            //    : from question in Entities.Questions
            //      where
            //          question.Title.Contains(criteria.Keyword)
            //      orderby question.PostedDate descending
            //      select question;
        }
コード例 #11
0
        public async Task <IEnumerable <Question> > GetQuestionsAsync(int from, int toTake)
        {
            ThrowIfDisposed();

            QuestionFilter filter = new QuestionFilter
            {
                From       = from,
                ToTake     = toTake,
                IsClosed   = false,
                IsVerified = true
            };

            IEnumerable <QuestionEntity> questions = await QuestionRepository.GetQuestionsAsync(filter, CancellationToken);

            var questionsResult = Mapper.Map <IEnumerable <QuestionEntity>, IEnumerable <Question> >(questions);

            return(questionsResult);
        }
コード例 #12
0
        public IEnumerable <QuestionDTO> Get(QuestionFilter questionfilter)
        {
            Expression <Func <Question, bool> > filter = s => s.Title != null;

            if (questionfilter.CategoryId.HasValue)
            {
                Expression <Func <Question, bool> > filterToAppend = s => s.CategoryId == questionfilter.CategoryId;
                filter = filter.And(filterToAppend);
            }
            if (questionfilter.LawyerQuestions)
            {
                Expression <Func <Question, bool> > filterToAppend = s => s.Answers.Any(w => w.User.LawyerId == questionfilter.LawyerId);
                filter = filter.And(filterToAppend);
            }

            if (questionfilter.UnAnswerd)
            {
                Expression <Func <Question, bool> > filterToAppend = s => !s.Answers.Any();
                filter = filter.And(filterToAppend);
            }

            return(QuestionRepository.Get(filter, includeProperties: "User,Answers,Answers.User").Select(s => QuestionDTO.ToQuestionDTO(s)));
        }
コード例 #13
0
 public GetTestResultByTestIdQuery(QuestionFilter filter)
 {
     Filter = filter;
 }
コード例 #14
0
 public GetTestQuestionOptionForEndUserByTestId(QuestionFilter filter)
 {
     Filter = filter;
 }
コード例 #15
0
        public async Task <IActionResult> GetTestResultByTestId([FromQuery] QuestionFilter filter)
        {
            var result = await _mediator.Send(new GetTestResultByTestIdQuery(filter));

            return(result);
        }
コード例 #16
0
 public GetQuestionFilterQuery(QuestionFilter filter)
 {
     Filter = filter;
 }
コード例 #17
0
        public async Task <IActionResult> GetAllUser([FromQuery] QuestionFilter filter)
        {
            var result = await _mediator.Send(new GetAllTestUserQuery(filter));

            return(result);
        }
コード例 #18
0
 public GetAllTestUserQuery(QuestionFilter filter)
 {
     Filter = filter;
 }
コード例 #19
0
        public async Task <IActionResult> GetQuestionById([FromQuery] QuestionFilter query)
        {
            var result = await _mediator.Send(new GetQuestionOptionByIdQuery(query));

            return(result);
        }
コード例 #20
0
        public async Task <IActionResult> GetQuestionCountbyCategoryId([FromQuery] QuestionFilter filter)
        {
            var result = await _mediator.Send(new GetQuestionCountQuery(filter));

            return(result);
        }
コード例 #21
0
        protected IQueryable <QuestionEntity> ApplyFilter(IQueryable <QuestionEntity> entities, QuestionFilter filter)
        {
            if (filter.IsClosed.HasValue)
            {
                entities = entities.Where(t => t.IsClosed == filter.IsClosed.Value);
            }

            if (filter.IsVerified.HasValue)
            {
                entities = entities.Where(t => t.IsVerified == filter.IsVerified.Value);
            }

            if (filter.From.HasValue || filter.ToTake.HasValue)
            {
                entities = entities.OrderBy(t => t.CreateDateTimeUTC);

                if (filter.From.HasValue)
                {
                    entities = entities.Skip(filter.From.Value);
                }

                if (filter.ToTake.HasValue)
                {
                    entities = entities.Take(filter.ToTake.Value);
                }
            }

            return(entities);
        }
コード例 #22
0
 public GetTestByCategoryId(QuestionFilter filter)
 {
     Filter = filter;
 }
コード例 #23
0
        public async Task <IActionResult> GetTraningDocument([FromQuery] QuestionFilter filter)
        {
            var result = await _mediator.Send(new GetTestQuestionOptionForEndUserByTestId(filter));

            return(result);
        }
コード例 #24
0
        public async Task <IActionResult> GetEndUserTests([FromQuery] QuestionFilter filter)
        {
            var result = await _mediator.Send(new GetTestsForEndUser());

            return(result);
        }
コード例 #25
0
 public GetQuestionOptionByIdQuery(QuestionFilter filter)
 {
     Filter = filter;
 }