Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        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();
        }