Exemplo n.º 1
0
        /// <summary>
        /// Set features based on existence of data.  This is used for assessments that were
        /// created prior to incorporating features into the assessment data model.
        /// </summary>
        /// <param name="assessment"></param>
        private void DetermineFeaturesFromData(ref AssessmentDetail assessment, CSET_Context db)
        {
            var a = assessment;

            if (db.AVAILABLE_STANDARDS.Any(x => x.Assessment_Id == a.Id))
            {
                assessment.UseStandard = true;
            }


            if (db.ASSESSMENT_DIAGRAM_COMPONENTS.Any(x => x.Assessment_Id == a.Id))
            {
                BusinessManagers.DiagramManager dm = new BusinessManagers.DiagramManager(db);
                assessment.UseDiagram = dm.HasDiagram(a.Id);
            }


            // determine if there are maturity answers and attach maturity models
            var maturityAnswers = db.ANSWER.Where(x => x.Assessment_Id == a.Id && x.Question_Type.ToLower() == "maturity").ToList();

            if (maturityAnswers.Count > 0)
            {
                assessment.UseMaturity = true;

                if (!db.AVAILABLE_MATURITY_MODELS.Any(x => x.Assessment_Id == a.Id))
                {
                    // determine the maturity models represented by the questions that have been answered
                    var qqq = db.MATURITY_QUESTIONS.Where(q => maturityAnswers.Select(x => x.Question_Or_Requirement_Id).Contains(q.Mat_Question_Id)).ToList();
                    var maturityModelIds = qqq.Select(x => x.Maturity_Model_Id).Distinct().ToList();
                    foreach (var modelId in maturityModelIds)
                    {
                        var mm = new AVAILABLE_MATURITY_MODELS()
                        {
                            Assessment_Id = a.Id,
                            model_id      = modelId,
                            Selected      = true
                        };

                        db.AVAILABLE_MATURITY_MODELS.Add(mm);
                        db.SaveChanges();

                        // get the newly-attached model for the response
                        var mmm = new MaturityManager();
                        assessment.MaturityModel = mmm.GetMaturityModel(a.Id);
                    }
                }
            }

            SaveAssessmentDetail(a.Id, assessment);
        }
Exemplo n.º 2
0
        private AVAILABLE_MATURITY_MODELS ProcessModelDefaults(CSET_Context db, int assessmentId, bool isAcetInstallation)
        {
            //if the available maturity model is not selected and the application is CSET
            //the default is EDM
            //if the application is ACET the default is ACET

            var myModel = db.AVAILABLE_MATURITY_MODELS
                          .Include(x => x.model_)
                          .Where(x => x.Assessment_Id == assessmentId).FirstOrDefault();

            if (myModel == null)
            {
                myModel = new AVAILABLE_MATURITY_MODELS()
                {
                    Assessment_Id = assessmentId,
                    model_id      = isAcetInstallation ? 1 : 3,
                    Selected      = true
                };
                db.AVAILABLE_MATURITY_MODELS.Add(myModel);
                db.SaveChanges();
            }

            return(myModel);
        }