Пример #1
0
        /// <summary>
        /// I don't like how this is not general but
        /// entity wants to keep the object references.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="db"></param>
        public void SaveToDb(int id, CSET_Context db)
        {
            NistProcessingLogic nistProcessing = new NistProcessingLogic();
            var dblist = db.CNSS_CIA_JUSTIFICATIONS.Where(x => x.Assessment_Id == id).AsEnumerable <CNSS_CIA_JUSTIFICATIONS>();
            Dictionary <String, CNSS_CIA_JUSTIFICATIONS> dbValues = dblist.ToDictionary(x => x.CIA_Type.ToLower(), x => x);

            CNSS_CIA_JUSTIFICATIONS cnvalu;

            // Availability
            if (!String.IsNullOrWhiteSpace(this.Availability_Special_Factor))
            {
                cnvalu = getOrCreateNew("availability", id, dbValues, db);
                cnvalu.Justification      = this.Availability_Special_Factor == null ? String.Empty : this.Availability_Special_Factor;
                cnvalu.DropDownValueLevel = this.Availability_Value.SALName;
            }

            // Confidentiality
            if (!String.IsNullOrWhiteSpace(this.Confidentiality_Special_Factor))
            {
                cnvalu = getOrCreateNew("confidentiality", id, dbValues, db);
                cnvalu.Justification      = this.Confidentiality_Special_Factor == null ? string.Empty : this.Confidentiality_Special_Factor;
                cnvalu.DropDownValueLevel = this.Confidentiality_Value.SALName;
            }

            // Integrity
            if (!String.IsNullOrWhiteSpace(this.Integrity_Special_Factor))
            {
                cnvalu = getOrCreateNew("integrity", id, dbValues, db);
                cnvalu.Justification      = this.Integrity_Special_Factor == null ? String.Empty : this.Integrity_Special_Factor;
                cnvalu.DropDownValueLevel = this.Integrity_Value.SALName;
            }

            db.SaveChanges();
            CSETWeb_Api.BusinessLogic.Helpers.AssessmentUtil.TouchAssessment(id);
        }
Пример #2
0
        public void loadFromDb(int assessmentId, CSET_Context db)
        {
            NistProcessingLogic            nistProcessing = new NistProcessingLogic();
            List <CNSS_CIA_JUSTIFICATIONS> ciavalues      = db.CNSS_CIA_JUSTIFICATIONS.Where(x => x.Assessment_Id == assessmentId).ToList <CNSS_CIA_JUSTIFICATIONS>();

            foreach (CNSS_CIA_JUSTIFICATIONS cia in ciavalues)
            {
                switch (cia.CIA_Type.ToLower())
                {
                case "availability":
                    this.Availability_Special_Factor = cia.Justification;
                    this.Availability_Value          = nistProcessing.GetWeightPair(cia.DropDownValueLevel.ToLower());
                    break;

                case "confidentiality":
                    this.Confidentiality_Special_Factor = cia.Justification;
                    this.Confidentiality_Value          = nistProcessing.GetWeightPair(cia.DropDownValueLevel.ToLower());
                    break;

                case "integrity":
                    this.Integrity_Special_Factor = cia.Justification;
                    this.Integrity_Value          = nistProcessing.GetWeightPair(cia.DropDownValueLevel.ToLower());
                    break;
                }
            }
        }