예제 #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 void SetDefaultSALs(int assessmentId)
        {
            try
            {
                using (CSET_Context db = new CSET_Context())
                {
                    TinyMapper.Bind <STANDARD_SELECTION, Sals>();
                    TinyMapper.Bind <Sals, STANDARD_SELECTION>();

                    STANDARD_SELECTION standardSelection = db.STANDARD_SELECTION.Find(assessmentId);

                    Sals sals = new Sals()
                    {
                        Selected_Sal_Level          = "Low",
                        Last_Sal_Determination_Type = "Simple",
                        CLevel = "Low",
                        ALevel = "Low",
                        ILevel = "Low"
                    };

                    standardSelection = TinyMapper.Map <STANDARD_SELECTION>(sals);
                    standardSelection.Assessment_Id    = assessmentId;
                    standardSelection.Application_Mode = AssessmentModeData.DetermineDefaultApplicationMode();

                    db.STANDARD_SELECTION.Add(standardSelection);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
예제 #3
0
        public string GetMode()
        {
            int assessmentId      = Auth.AssessmentForUser();
            QuestionsManager qm   = new QuestionsManager(assessmentId);
            string           mode = GetApplicationMode(assessmentId).Trim().Substring(0, 1);

            if (String.IsNullOrEmpty(mode))
            {
                mode = AssessmentModeData.DetermineDefaultApplicationModeAbbrev();
                SetMode(mode);
            }

            return(mode);
        }
예제 #4
0
        public IHttpActionResult GetSTANDARD_SELECTION()
        {
            try
            {
                int asssessmentId = Auth.AssessmentForUser();

                TinyMapper.Bind <STANDARD_SELECTION, Sals>();
                TinyMapper.Bind <Sals, STANDARD_SELECTION>();

                STANDARD_SELECTION sTANDARD_SELECTION = db.STANDARD_SELECTION.Find(asssessmentId);
                Sals rsal;
                if (sTANDARD_SELECTION == null)
                {
                    rsal = new Sals()
                    {
                        Selected_Sal_Level          = "Low",
                        Last_Sal_Determination_Type = "Simple",
                        CLevel = "Low",
                        ALevel = "Low",
                        ILevel = "Low"
                    };
                    sTANDARD_SELECTION = TinyMapper.Map <STANDARD_SELECTION>(rsal);
                    sTANDARD_SELECTION.Assessment_Id    = asssessmentId;
                    sTANDARD_SELECTION.Application_Mode = AssessmentModeData.DetermineDefaultApplicationMode();
                    db.STANDARD_SELECTION.Add(sTANDARD_SELECTION);
                    db.SaveChanges();
                }
                else
                {
                    rsal = TinyMapper.Map <Sals>(sTANDARD_SELECTION);
                }

                LevelManager lm = new LevelManager(asssessmentId, db);
                lm.RetrieveOtherLevels(rsal);
                StandardRepository sr = new StandardRepository(asssessmentId, lm, new StandardManager(), new AssessmentModeData(db, asssessmentId), new StandardSpecficLevelRepository(db));
                sr.Confidence_Level   = rsal.CLevel;
                sr.Integrity_Level    = rsal.ILevel;
                sr.Availability_Level = rsal.ALevel;
                //if(!rsal.SelectedSALOverride)
                //   rsal.Selected_Sal_Level = sr.Selected_Sal_Level;

                return(Ok(rsal));
            }
            catch (Exception)
            {
                return(Conflict());
                //return (HttpResponseMessage)CSETWeb_Api.Helpers.ElmahWrapper.LogAndReportException(e, Request, HttpContext.Current);
            }
        }
예제 #5
0
        /// <summary>
        /// Determines if the assessment is question or requirements based.
        /// </summary>
        /// <param name="assessmentId"></param>
        /// <returns></returns>
        protected string GetApplicationMode(int assessmentId)
        {
            using (var db = new CSET_Context())
            {
                var mode = db.STANDARD_SELECTION.Where(x => x.Assessment_Id == assessmentId).Select(x => x.Application_Mode).FirstOrDefault();

                if (mode == null)
                {
                    mode = AssessmentModeData.DetermineDefaultApplicationModeAbbrev();
                    SetMode(mode);
                }

                return(mode);
            }
        }
예제 #6
0
파일: SalManager.cs 프로젝트: itcms/cset
        private void setdefault(CSET_Context db, int assessmentId)
        {
            TinyMapper.Bind <STANDARD_SELECTION, Sals>();
            TinyMapper.Bind <Sals, STANDARD_SELECTION>();

            STANDARD_SELECTION standardSelection = db.STANDARD_SELECTION.Find(assessmentId);

            Sals sals = new Sals()
            {
                Selected_Sal_Level          = "Low",
                Last_Sal_Determination_Type = "Simple",
                CLevel = "Low",
                ALevel = "Low",
                ILevel = "Low"
            };

            standardSelection = TinyMapper.Map <STANDARD_SELECTION>(sals);
            standardSelection.Assessment_Id    = assessmentId;
            standardSelection.Application_Mode = AssessmentModeData.DetermineDefaultApplicationMode();

            db.STANDARD_SELECTION.Add(standardSelection);
            db.SaveChanges();
        }
        /// <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);
        }