Exemple #1
0
        private void InitializeWorkQuestionnaires()
        {
            var repository = Binds.Injector.GetInstance <Repository.WorkQuestionnaireRepository>(null, new object[] { _context }) as Repository.WorkQuestionnaireRepository;
            var items      = repository.All();

            var workQuestionnaireList = new List <WorkQuestionnaireViewModel>();

            foreach (var item in items)
            {
                var workQuestionnaireItem = new WorkQuestionnaireViewModel(item);

                workQuestionnaireList.Add(workQuestionnaireItem);
            }

            WorkQuestionnaires = workQuestionnaireList.ToArray();
        }
Exemple #2
0
        private void InitializeWorkQuestionnaire(WorkQuestionnaireViewModel workQuestionnaireCurrent)
        {
            if (workQuestionnaireCurrent.Questions == null && workQuestionnaireCurrent.WorkQuestionnaire.ExpertAnswers != null)
            {
                var questionDictionary = new Dictionary <int, QuestionViewModel>();

                foreach (var q in workQuestionnaireCurrent.WorkQuestionnaire.Questionnaire.Question)
                {
                    var question = new QuestionViewModel(q.Key, q.Text, new List <Entity.ExpertAnswer>());
                    questionDictionary.Add(q.Key, question);

                    foreach (var expert in workQuestionnaireCurrent.WorkQuestionnaire.ExpertGroup.Experts)
                    {
                        (question.Experts as List <Entity.ExpertAnswer>).Add(new Entity.ExpertAnswer()
                        {
                            Expert = new Entity.User(expert.Expert)
                        });
                    }
                }

                foreach (var expertAnswer in workQuestionnaireCurrent.WorkQuestionnaire.ExpertAnswers)
                {
                    if (expertAnswer.IsAnswer && questionDictionary.ContainsKey(expertAnswer.Answer.QuestionKey))
                    {
                        var q = questionDictionary[expertAnswer.Answer.QuestionKey];

                        foreach (var expert in q.Experts)
                        {
                            if (expert.Expert.Key == expertAnswer.ExpertKey)
                            {
                                expert.Answer   = new Entity.Answer(expertAnswer.Answer);
                                expert.IsAnswer = expertAnswer.IsAnswer;
                            }
                        }
                    }
                }

                workQuestionnaireCurrent.Questions = questionDictionary.Values.OrderBy(x => x.Order).ToArray();
            }
        }