コード例 #1
0
        public Sals BuildFromRow(DataRow row)
        {
            var returnRecord = Sals.BuildSalsFromRow(row);

            returnRecord = this.BuildExtraFromRow <Sals>(returnRecord, row);
            return(returnRecord);
        }
コード例 #2
0
ファイル: SalManager.cs プロジェクト: vcubefame/CSET
        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 Sals Insert(Sals record)
        {
            DataRow row = this.dataSet.ttblsals.NewttblsalsRow();

            this.UpdateToRow(ref row, record);
            this.ExtraUpdateToRow(ref row, record);
            this.dataSet.ttblsals.AddttblsalsRow((pdssalsDataSet.ttblsalsRow)row);
            this.SaveChanges();
            return(this.dataSet.ttblsals.Rows.Count > 0 ? this.BuildFromRow(this.dataSet.ttblsals.Rows[0]) : null);
        }
コード例 #4
0
        public Sals GetByRowId(string rowId, string fldList)
        {
            var  row  = this.GetRowByRowId(rowId, fldList);
            Sals sals = null;

            if (row != null)
            {
                sals = this.BuildFromRow(row);
            }
            return(sals);
        }
コード例 #5
0
        private Sals CalculateOveralls(int assessmentId, CSET_Context db)
        {
            Sals rval = CalculatedNist(assessmentId, db);
            STANDARD_SELECTION sTANDARD_SELECTION = db.STANDARD_SELECTION.Where(x => x.Assessment_Id == assessmentId).FirstOrDefault();

            sTANDARD_SELECTION.Selected_Sal_Level = rval.Selected_Sal_Level;
            LevelManager lm = new LevelManager(assessmentId, db);

            lm.SaveOtherLevels(assessmentId, rval);
            db.SaveChanges();
            return(rval);
        }
コード例 #6
0
        protected Sals Fetch(string where, int batchsize, string fldList)
        {
            this.FetchWhere(where, batchsize, fldList);
            var  row  = this.dataSet.ttblsals.AsEnumerable().SingleOrDefault();
            Sals sals = null;

            if (row != null)
            {
                sals = this.BuildFromRow(row);
            }
            return(sals);
        }
コード例 #7
0
        public IActionResult Create([FromBody] SalesViewModel formData)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(new ApiBadRequestResponse(ModelState)));
                }

                var objSales = new Sals();
            }
        }
コード例 #8
0
        public void Delete(Sals record)
        {
            var row = this.GetRowByRowId(record.rowID, string.Empty);

            if (row == null)
            {
                row = this.dataSet.ttblsals.NewttblsalsRow();
                Sals.BuildMinimalRow(ref row, record);
                this.dataSet.ttblsals.AddttblsalsRow((pdssalsDataSet.ttblsalsRow)row);
            }
            row.Delete();
            this.SaveChanges();
        }
コード例 #9
0
        public Sals Update(Sals record)
        {
            var row = this.GetRowByRowId(record.rowID, string.Empty);

            if (row != null)
            {
                this.UpdateToRow(ref row, record);
                this.ExtraUpdateToRow(ref row, record);
                this.SaveChanges();
                return(this.dataSet.ttblsals.Rows.Count > 0 ? this.BuildFromRow(this.dataSet.ttblsals.Rows[0]) : null);
            }
            ErrorReportingHelper.ReportErrors("global.update.doesnotexist", 421);
            return(null);
        }
コード例 #10
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);
            }
        }
コード例 #11
0
        public Sals CalculatedNist(int assessmentId, CSET_Context db)
        {
            NistProcessingLogic nistProcessing = new NistProcessingLogic();

            nistProcessing.CalcLevels(assessmentId, db);
            Sals rval = new Sals()
            {
                ALevel             = nistProcessing.highestQuestionAvailabilityValue.SALName,
                CLevel             = nistProcessing.highestQuestionConfidentialityValue.SALName,
                ILevel             = nistProcessing.highestQuestionIntegrityValue.SALName,
                Selected_Sal_Level = nistProcessing.HighestOverallNISTSALLevel.SALName
            };

            return(rval);
        }
コード例 #12
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();
        }
コード例 #13
0
 public Sals Update(Sals record)
 {
     return(this.adapter.Update(record));
 }
コード例 #14
0
        public IHttpActionResult PostSAL(Sals tmpsal)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            int assessmentId = Auth.AssessmentForUser();

            TinyMapper.Bind <Sals, STANDARD_SELECTION>();
            STANDARD_SELECTION sTANDARD_SELECTION = db.STANDARD_SELECTION.Where(x => x.Assessment_Id == assessmentId).FirstOrDefault();

            if (sTANDARD_SELECTION != null)
            {
                sTANDARD_SELECTION = TinyMapper.Map <Sals, STANDARD_SELECTION>(tmpsal, sTANDARD_SELECTION);
            }
            else
            {
                sTANDARD_SELECTION = TinyMapper.Map <STANDARD_SELECTION>(tmpsal);
            }
            sTANDARD_SELECTION.Assessment_Id = assessmentId;


            db.Entry(sTANDARD_SELECTION).State = EntityState.Modified;
            LevelManager lm = new LevelManager(assessmentId, db);

            lm.SaveOtherLevels(assessmentId, tmpsal);
            lm.Init(sTANDARD_SELECTION);
            if (tmpsal.SelectedSALOverride)
            {
                lm.SaveSALLevel(tmpsal.Selected_Sal_Level);
            }

            try
            {
                db.SaveChanges();

                StandardRepository sr = new StandardRepository(assessmentId, lm, new StandardManager(), new AssessmentModeData(db, assessmentId), new StandardSpecficLevelRepository(db));
                sr.Confidence_Level   = tmpsal.CLevel;
                sr.Integrity_Level    = tmpsal.ILevel;
                sr.Availability_Level = tmpsal.ALevel;

                // save the newly-calculated overall value
                if (!tmpsal.SelectedSALOverride)
                {
                    tmpsal.Selected_Sal_Level = sr.Selected_Sal_Level;
                    lm.SaveSALLevel(tmpsal.Selected_Sal_Level);
                }

                return(Ok(tmpsal));
            }
            catch (DbUpdateConcurrencyException dbe)
            {
                if (!STANDARD_SELECTIONExists(assessmentId))
                {
                    return(NotFound());
                }
                else
                {
                    throw dbe;
                }
            }
            catch (Exception e)
            {
                CSETWeb_Api.Helpers.ElmahWrapper.LogAndReportException(e, Request, HttpContext.Current);
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #15
0
 public Sals Update(Sals record)
 {
     return(this.repository.Update(record));
 }
コード例 #16
0
 public void Delete(Sals record)
 {
     this.repository.Delete(record);
 }
コード例 #17
0
 public void RetrieveOtherLevels(Sals tmpsal)
 {
     tmpsal.CLevel = getLevel(CONFIDENCE_LEVEL_CNSSI);
     tmpsal.ILevel = getLevel(INTEGRITY_LEVEL_CNSSI);
     tmpsal.ALevel = getLevel(AVAILABLILTY_LEVEL_CNSSI);
 }
コード例 #18
0
 public void UpdateToRow(ref DataRow row, Sals record)
 {
     Sals.UpdateRowFromSals(ref row, record);
     this.ExtraUpdateToRow(ref row, record);
 }
コード例 #19
0
 public void SaveOtherLevels(int id, Sals tmpsal)
 {
     this.SaveSelectedLevels(id, CONFIDENCE_LEVEL_CNSSI, tmpsal.CLevel);
     this.SaveSelectedLevels(id, INTEGRITY_LEVEL_CNSSI, tmpsal.ILevel);
     this.SaveSelectedLevels(id, AVAILABLILTY_LEVEL_CNSSI, tmpsal.ALevel);
 }
コード例 #20
0
 public void Delete(Sals record)
 {
     this.adapter.Delete(record);
 }
コード例 #21
0
 public Sals Insert(Sals record)
 {
     return(this.repository.Insert(record));
 }
コード例 #22
0
 public Sals Insert(Sals record)
 {
     return(this.adapter.Insert(record));
 }