Beispiel #1
0
        public IEnumerable <PreQualificationQuestionViewModel> GetPreQualificationQuestionsbyTemplateIds(IEnumerable <long> templateIds)
        {
            if (!templateIds.Any())
            {
                return(new List <PreQualificationQuestionViewModel>());
            }

            var preQualificationTestTemplates = _preQualificationTestTemplateRepository.GetByTemplateIds(templateIds);

            if (preQualificationTestTemplates.IsNullOrEmpty())
            {
                return(null);
            }

            var testIds = preQualificationTestTemplates.Select(x => x.TestId);
            var tests   = _testRepository.GetTestByIds(testIds);

            var questions                = _preQualificationQuestionRepository.GetQuestionsByTemplateIds(templateIds.ToArray());
            var questionIds              = questions.IsNullOrEmpty() ? null : questions.Select(x => x.Id).ToArray();
            var dependencyRule           = _preQualificationQuestionRuleRepository.Get().Where(x => questionIds.Contains(x.QuestionId));
            var templateIdQuestionIdPair = _preQualificationTestTemplateRepository.GetTemplateIdQuestionIdPairByTemplateIds(templateIds.ToArray());

            return(_preQualifiedQuestionTemplateFactory.GetPreQualificationQuestionListModel(preQualificationTestTemplates, tests, questions, templateIdQuestionIdPair, dependencyRule));
        }