Пример #1
0
        internal List <QuestionInformationTabData> getQuestionDetails(int?questionId, int assessmentId, bool IsComponent)
        {
            if (questionId == null)
            {
                SetQuestionInfoTabToEmpty();
                return(ListTabs);
            }

            this.IsNoQuestion          = false;
            this.IsDetailAndInfo       = true;
            this.ShowQuestionDetailTab = false;


            if (questionId != null)
            {
                AssessmentModeData mode = new AssessmentModeData(this.DataContext, assessmentId);
                bool IsRequirement      = IsComponent ? !IsComponent : mode.IsRequirement;
                var  newqp     = this.DataContext.NEW_QUESTION.Where(q => q.Question_Id == questionId).FirstOrDefault();
                var  newAnswer = this.DataContext.ANSWER.Where(a => a.Question_Or_Requirement_Id == questionId &&
                                                               a.Is_Requirement == IsRequirement && a.Assessment_Id == assessmentId).FirstOrDefault();
                var gettheselectedsets = this.DataContext.AVAILABLE_STANDARDS.Where(x => x.Assessment_Id == assessmentId);

                if (newAnswer == null)
                {
                    newAnswer = new ANSWER()
                    {
                        Is_Requirement             = IsRequirement,
                        Question_Or_Requirement_Id = questionId ?? 0,
                        Answer_Text     = AnswerEnum.UNANSWERED.GetStringAttribute(),
                        Mark_For_Review = false,
                        Reviewed        = false,
                        Is_Component    = false
                    };
                    DataContext.ANSWER.Add(newAnswer);
                }
                var qp = new QuestionPoco(newAnswer, newqp);
                qp.DictionaryStandards = (from a in this.DataContext.AVAILABLE_STANDARDS
                                          join b in this.DataContext.SETS on a.Set_Name equals b.Set_Name
                                          where a.Selected == true &&
                                          a.Assessment_Id == assessmentId
                                          select b
                                          ).ToDictionary(x => x.Set_Name, x => x);

                qp.DefaultSetName = qp.DictionaryStandards.Keys.FirstOrDefault();
                qp.SetName        = qp.DictionaryStandards.Keys.FirstOrDefault();
                LoadData(qp, assessmentId);

                // Get any findings/discoveries for the question
                FindingsViewModel fm = new FindingsViewModel(this.DataContext, assessmentId, newAnswer.Answer_Id);
                this.Findings = fm.AllFindings();

                // Get any documents attached to the question
                DocumentManager dm = new DocumentManager(assessmentId);
                this.Documents = dm.GetDocumentsForAnswer(newAnswer.Answer_Id);

                //Get any components
            }

            return(ListTabs);
        }
Пример #2
0
        public List <Finding> AllDiscoveries([FromUri] int Answer_Id)
        {
            int assessmentId = Auth.AssessmentForUser();

            using (CSET_Context context = new CSET_Context())
            {
                FindingsViewModel fm = new FindingsViewModel(context, assessmentId, Answer_Id);
                return(fm.AllFindings());
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="questionId"></param>
        /// <param name="assessmentId"></param>
        /// <param name="IsComponent"></param>
        /// <param name="IsMaturity"></param>
        /// <returns></returns>
        internal List <QuestionInformationTabData> GetQuestionDetails(int?questionId, int assessmentId, string questionType)
        {
            if (questionId == null)
            {
                SetQuestionInfoTabToEmpty();
                return(ListTabs);
            }

            this.IsNoQuestion          = false;
            this.IsDetailAndInfo       = true;
            this.ShowQuestionDetailTab = false;


            if (questionId != null)
            {
                var selectedSets = this.DataContext.AVAILABLE_STANDARDS.Where(x => x.Assessment_Id == assessmentId);

                AssessmentModeData mode = new AssessmentModeData(this.DataContext, assessmentId);
                bool IsQuestion         = mode.IsQuestion;
                // bool IsRequirement = IsComponent ? !IsComponent : mode.IsRequirement;

                var newqp     = this.DataContext.NEW_QUESTION.Where(q => q.Question_Id == questionId).FirstOrDefault();
                var newAnswer = this.DataContext.ANSWER.Where(a =>
                                                              a.Question_Or_Requirement_Id == questionId &&
                                                              a.Assessment_Id == assessmentId &&
                                                              a.Question_Type == questionType).FirstOrDefault();


                if (newAnswer == null)
                {
                    newAnswer = new ANSWER()
                    {
                        Question_Type = questionType,
                        Question_Or_Requirement_Id = questionId ?? 0,
                        Answer_Text     = AnswerEnum.UNANSWERED.GetStringAttribute(),
                        Mark_For_Review = false,
                        Reviewed        = false,
                        Is_Component    = false
                    };

                    // set the question type booleans, for consistency
                    newAnswer.Is_Component   = newAnswer.Question_Type == "Component";
                    newAnswer.Is_Requirement = newAnswer.Question_Type == "Requirement";
                    newAnswer.Is_Maturity    = newAnswer.Question_Type == "Maturity";


                    DataContext.ANSWER.Add(newAnswer);
                }

                QuestionPoco qp = null;

                if (questionType == "Maturity")
                {
                    var matQuestion = this.DataContext.MATURITY_QUESTIONS.Where(q => q.Mat_Question_Id == questionId).FirstOrDefault();
                    qp = new QuestionPoco(newAnswer, matQuestion);
                }
                else
                {
                    qp = new QuestionPoco(newAnswer, newqp);
                }

                qp.DictionaryStandards = (from a in this.DataContext.AVAILABLE_STANDARDS
                                          join b in this.DataContext.SETS on a.Set_Name equals b.Set_Name
                                          where a.Selected == true &&
                                          a.Assessment_Id == assessmentId
                                          select b
                                          ).ToDictionary(x => x.Set_Name, x => x);

                qp.DefaultSetName = qp.DictionaryStandards.Keys.FirstOrDefault();
                qp.SetName        = qp.DictionaryStandards.Keys.FirstOrDefault();

                LoadData(qp, assessmentId);

                // Get any findings/discoveries for the question
                FindingsViewModel fm = new FindingsViewModel(this.DataContext, assessmentId, newAnswer.Answer_Id);
                this.Findings = fm.AllFindings();

                // Get any documents attached to the question
                DocumentManager dm = new DocumentManager(assessmentId);
                this.Documents = dm.GetDocumentsForAnswer(newAnswer.Answer_Id);

                //Get any components
            }

            var json = JsonConvert.SerializeObject(ListTabs);

            return(ListTabs);
        }