Пример #1
0
        public QuestionDTO GetById(int id)
        {
            var quest = QuestionRepository.Get(s => s.Id == id, includeProperties: "User,Answers,Answers.User").FirstOrDefault();

            return(QuestionDTO.ToQuestionDTO(quest));
        }
Пример #2
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)));
        }