示例#1
0
        /// <summary>
        /// Persists data to the ASSESSMENTS and INFORMATION tables.
        /// Date fields should be converted to UTC before sending the Assessment
        /// to this method.
        /// </summary>
        /// <param name="assessment"></param>
        /// <returns></returns>
        public int SaveAssessmentDetail(int assessmentId, AssessmentDetail assessment)
        {
            var          db       = new DataLayerCore.Model.CSET_Context();
            TokenManager tm       = new TokenManager();
            string       app_code = tm.Payload(Constants.Token_Scope);
            // Add or update the ASSESSMENT record
            var dbAssessment = new ASSESSMENTS()
            {
                Assessment_Id         = assessment.Id,
                AssessmentCreatedDate = assessment.CreatedDate,
                AssessmentCreatorId   = assessment.CreatorId,
                Assessment_Date       = assessment.AssessmentDate ?? DateTime.Now,
                LastAccessedDate      = assessment.LastModifiedDate,
                Charter                  = string.IsNullOrEmpty(assessment.Charter) ? string.Empty : assessment.Charter.PadLeft(5, '0'),
                CreditUnionName          = assessment.CreditUnion,
                Assets                   = assessment.Assets,
                MatDetail_targetBandOnly = app_code == "ACET"
            };

            db.ASSESSMENTS.AddOrUpdate(dbAssessment, x => x.Assessment_Id);

            db.SaveChanges();
            assessmentId = dbAssessment.Assessment_Id;
            var user = db.USERS.FirstOrDefault(x => x.UserId == dbAssessment.AssessmentCreatorId);
            // then use its key for the INFORMATION record
            var dbInfo = new INFORMATION
            {
                Id = assessmentId,
                Assessment_Name               = assessment.AssessmentName,
                Facility_Name                 = assessment.FacilityName,
                City_Or_Site_Name             = assessment.CityOrSiteName,
                State_Province_Or_Region      = assessment.StateProvRegion,
                Executive_Summary             = assessment.ExecutiveSummary,
                Assessment_Description        = assessment.AssessmentDescription,
                Additional_Notes_And_Comments = assessment.AdditionalNotesAndComments,
                IsAcetOnly = assessment.IsAcetOnly
            };

            db.INFORMATION.AddOrUpdate(dbInfo, x => x.Id);

            db.SaveChanges();


            AssessmentUtil.TouchAssessment(assessmentId);


            return(dbInfo.Id);
        }
示例#2
0
        /// <summary>
        /// Persists data to the ASSESSMENTS and INFORMATION tables.
        /// Date fields should be converted to UTC before sending the Assessment
        /// to this method.
        /// </summary>
        /// <param name="assessment"></param>
        /// <returns></returns>
        public int SaveAssessmentDetail(int assessmentId, AssessmentDetail assessment)
        {
            var db = new DataLayerCore.Model.CSET_Context();

            // Add or update the ASSESSMENT record
            var dbAssessment = new ASSESSMENTS()
            {
                Assessment_Id         = assessment.Id,
                AssessmentCreatedDate = assessment.CreatedDate,
                AssessmentCreatorId   = assessment.CreatorId,
                Assessment_Date       = assessment.AssessmentDate ?? DateTime.Now,
                LastAccessedDate      = assessment.LastModifiedDate,
                Charter         = assessment.Charter,
                CreditUnionName = assessment.CreditUnion,
                Assets          = assessment.Assets
            };

            db.ASSESSMENTS.AddOrUpdate(dbAssessment, x => x.Assessment_Id);

            db.SaveChanges();
            assessmentId = dbAssessment.Assessment_Id;
            var user = db.USERS.FirstOrDefault(x => x.UserId == dbAssessment.AssessmentCreatorId);
            // then use its key for the INFORMATION record
            var dbInfo = new INFORMATION
            {
                Id = assessmentId,
                Assessment_Name               = assessment.AssessmentName,
                Facility_Name                 = assessment.FacilityName,
                City_Or_Site_Name             = assessment.CityOrSiteName,
                State_Province_Or_Region      = assessment.StateProvRegion,
                Executive_Summary             = assessment.ExecutiveSummary,
                Assessment_Description        = assessment.AssessmentDescription,
                Additional_Notes_And_Comments = assessment.AdditionalNotesAndComments
            };

            db.INFORMATION.AddOrUpdate(dbInfo, x => x.Id);

            db.SaveChanges();


            AssessmentUtil.TouchAssessment(assessmentId);


            return(dbInfo.Id);
        }
示例#3
0
        /// <summary>
        /// Persists data to the ASSESSMENTS and INFORMATION tables.
        /// Date fields should be converted to UTC before sending the Assessment
        /// to this method.
        /// </summary>
        /// <param name="assessment"></param>
        /// <returns></returns>
        public int SaveAssessmentDetail(int assessmentId, AssessmentDetail assessment)
        {
            using (var db = new DataLayerCore.Model.CSET_Context())
            {
                TokenManager tm       = new TokenManager();
                string       app_code = tm.Payload(Constants.Token_Scope);

                // Add or update the ASSESSMENTS record
                var dbAssessment = db.ASSESSMENTS.Where(x => x.Assessment_Id == assessmentId).FirstOrDefault();

                if (dbAssessment == null)
                {
                    dbAssessment = new ASSESSMENTS();
                    db.ASSESSMENTS.Add(dbAssessment);
                    db.SaveChanges();
                    assessmentId = dbAssessment.Assessment_Id;
                }

                dbAssessment.Assessment_Id         = assessmentId;
                dbAssessment.AssessmentCreatedDate = assessment.CreatedDate;
                dbAssessment.AssessmentCreatorId   = assessment.CreatorId;
                dbAssessment.Assessment_Date       = assessment.AssessmentDate ?? DateTime.Now;
                dbAssessment.LastAccessedDate      = assessment.LastModifiedDate;
                dbAssessment.Charter                  = string.IsNullOrEmpty(assessment.Charter) ? string.Empty : assessment.Charter.PadLeft(5, '0');
                dbAssessment.CreditUnionName          = assessment.CreditUnion;
                dbAssessment.Assets                   = assessment.Assets;
                dbAssessment.MatDetail_targetBandOnly = (app_code == "ACET");
                dbAssessment.AnalyzeDiagram           = false;

                db.ASSESSMENTS.AddOrUpdate(dbAssessment, x => x.Assessment_Id);
                db.SaveChanges();


                var user = db.USERS.FirstOrDefault(x => x.UserId == dbAssessment.AssessmentCreatorId);


                var dbInformation = db.INFORMATION.Where(x => x.Id == assessmentId).FirstOrDefault();
                if (dbInformation == null)
                {
                    dbInformation = new INFORMATION()
                    {
                        Id = assessmentId
                    };
                }

                // add or update the INFORMATION record
                dbInformation.Assessment_Name               = assessment.AssessmentName;
                dbInformation.Facility_Name                 = assessment.FacilityName;
                dbInformation.City_Or_Site_Name             = assessment.CityOrSiteName;
                dbInformation.State_Province_Or_Region      = assessment.StateProvRegion;
                dbInformation.Executive_Summary             = assessment.ExecutiveSummary;
                dbInformation.Assessment_Description        = assessment.AssessmentDescription;
                dbInformation.Additional_Notes_And_Comments = assessment.AdditionalNotesAndComments;
                dbInformation.IsAcetOnly = assessment.IsAcetOnly;

                db.INFORMATION.AddOrUpdate(dbInformation, x => x.Id);
                db.SaveChanges();


                AssessmentUtil.TouchAssessment(assessmentId);

                return(assessmentId);
            }
        }
示例#4
0
        /// <summary>
        /// Persists data to the ASSESSMENTS and INFORMATION tables.
        /// Date fields should be converted to UTC before sending the Assessment
        /// to this method.
        /// </summary>
        /// <param name="assessment"></param>
        /// <returns></returns>
        public int SaveAssessmentDetail(int assessmentId, AssessmentDetail assessment)
        {
            using (var db = new DataLayerCore.Model.CSET_Context())
            {
                TokenManager tm       = new TokenManager();
                string       app_code = tm.Payload(Constants.Token_Scope);

                // Add or update the ASSESSMENTS record
                var dbAssessment = db.ASSESSMENTS.Where(x => x.Assessment_Id == assessmentId).FirstOrDefault();

                if (dbAssessment == null)
                {
                    dbAssessment = new ASSESSMENTS();
                    db.ASSESSMENTS.Add(dbAssessment);
                    db.SaveChanges();
                    assessmentId = dbAssessment.Assessment_Id;
                }

                dbAssessment.Assessment_Id         = assessmentId;
                dbAssessment.AssessmentCreatedDate = assessment.CreatedDate;
                dbAssessment.AssessmentCreatorId   = assessment.CreatorId;
                dbAssessment.Assessment_Date       = assessment.AssessmentDate ?? DateTime.Now;
                dbAssessment.LastAccessedDate      = assessment.LastModifiedDate;

                dbAssessment.UseDiagram  = assessment.UseDiagram;
                dbAssessment.UseMaturity = assessment.UseMaturity;
                dbAssessment.UseStandard = assessment.UseStandard;

                dbAssessment.Charter                  = string.IsNullOrEmpty(assessment.Charter) ? string.Empty : assessment.Charter.PadLeft(5, '0');
                dbAssessment.CreditUnionName          = assessment.CreditUnion;
                dbAssessment.Assets                   = assessment.Assets;
                dbAssessment.MatDetail_targetBandOnly = (app_code == "ACET");

                dbAssessment.Diagram_Markup = assessment.DiagramMarkup;
                dbAssessment.Diagram_Image  = assessment.DiagramImage;
                dbAssessment.AnalyzeDiagram = false;

                db.ASSESSMENTS.AddOrUpdate(dbAssessment, x => x.Assessment_Id);
                db.SaveChanges();


                var user = db.USERS.FirstOrDefault(x => x.UserId == dbAssessment.AssessmentCreatorId);


                var dbInformation = db.INFORMATION.Where(x => x.Id == assessmentId).FirstOrDefault();
                if (dbInformation == null)
                {
                    dbInformation = new INFORMATION()
                    {
                        Id = assessmentId
                    };
                }

                // add or update the INFORMATION record
                dbInformation.Assessment_Name               = assessment.AssessmentName;
                dbInformation.Facility_Name                 = assessment.FacilityName;
                dbInformation.City_Or_Site_Name             = assessment.CityOrSiteName;
                dbInformation.State_Province_Or_Region      = assessment.StateProvRegion;
                dbInformation.Executive_Summary             = assessment.ExecutiveSummary;
                dbInformation.Assessment_Description        = assessment.AssessmentDescription;
                dbInformation.Additional_Notes_And_Comments = assessment.AdditionalNotesAndComments;
                dbInformation.IsAcetOnly = assessment.IsAcetOnly;

                db.INFORMATION.AddOrUpdate(dbInformation, x => x.Id);
                db.SaveChanges();

                if (assessment.UseMaturity)
                {
                    SalManager salManager = new SalManager();
                    salManager.SetDefaultSAL_IfNotSet(assessmentId);
                    //this is at the bottom deliberatly because
                    //we want everything else to succeed first
                    MaturityManager mm = new MaturityManager();
                    mm.PersistSelectedMaturityModel(assessmentId, "CMMC");
                    if (mm.GetMaturityLevel(assessmentId) == 0)
                    {
                        mm.PersistMaturityLevel(assessmentId, 1);
                    }
                }

                AssessmentUtil.TouchAssessment(assessmentId);

                return(assessmentId);
            }
        }