コード例 #1
0
        public void UpdateAssessment(Assessment assessment)
        {
            var ToUpdate = GetAssessment(assessment.id);

            if (ToUpdate == null)
            {
                throw new Exception("the assessment to update not found");
            }
            using (var db = new Project_Db_Context())
            {
                foreach (Location_ l in assessment.Locations)
                {
                    db.Locations.Add(l);
                    db.SaveChanges();
                }
                db.Entry(assessment);
                db.Assessments.AddOrUpdate(assessment);
                db.SaveChanges();
            }
        }
コード例 #2
0
        public void AddAssessment(Assessment assessment)
        {
            var ToAdd = GetAssessment(assessment.id);

            if (ToAdd != null)
            {
                throw new Exception("An Assessment with an identical id already exists...");
            }
            using (var db = new Project_Db_Context())
            {
                db.Assessments.Add(assessment);
                db.SaveChanges();
            }
        }
コード例 #3
0
        public void RemoveReport(int id)
        {
            Report ToRemove = GetReport(id);

            if (ToRemove == null)
            {
                throw new Exception("An report with this ID does not exist..");
            }
            using (var db = new Project_Db_Context())
            {
                db.Reports.Remove(ToRemove);
                db.SaveChanges();
            }
        }
コード例 #4
0
        public void RemoveLocation(int id)
        {
            Location_ ToRemove = GetLocation(id);

            if (ToRemove == null)
            {
                throw new Exception("An Assessment with this ID does not exist..");
            }
            using (var db = new Project_Db_Context())
            {
                db.Locations.Remove(ToRemove);
                db.SaveChanges();
            }
        }
コード例 #5
0
        public void AddLocation(Location_ location)
        {
            var toAdd = GetLocation(location.id);

            if (toAdd != null)
            {
                throw new Exception("An Location with an identical id already exists...");
            }
            using (var db = new Project_Db_Context())
            {
                db.Locations.Add(location);
                db.SaveChanges();
            }
        }
コード例 #6
0
        public void AddFall(Fall fall)
        {
            var ToAdd = GetFall(fall.id);

            if (ToAdd != null)
            {
                throw new Exception("An Fall with an identical id already exists...");
            }
            using (var db = new Project_Db_Context())
            {
                db.Falls.Add(fall);
                db.SaveChanges();
            }
        }
コード例 #7
0
        public void RemoveAssessment(int _id)
        {
            Assessment ToRemove = GetAssessment(_id);

            if (ToRemove == null)
            {
                throw new Exception("An Assessment with this ID does not exist..");
            }
            using (var db = new Project_Db_Context())
            {
                db.Assessments.Remove(ToRemove);
                db.SaveChanges();
            }
        }
コード例 #8
0
        public void UpdateReport(Report report)
        {
            var ToUpdate = GetReport(report.id);

            if (ToUpdate == null)
            {
                throw new Exception("the report to update not found");
            }
            using (var db = new Project_Db_Context())
            {
                db.Entry(report);
                db.Reports.AddOrUpdate(report);
                db.SaveChanges();
            }
        }
コード例 #9
0
        public void UpdateFall(Fall fall)
        {
            var ToUpdate = GetFall(fall.id);

            if (ToUpdate == null)
            {
                throw new Exception("the assessment to update not found");
            }
            using (var db = new Project_Db_Context())
            {
                db.Entry(fall);
                db.Falls.AddOrUpdate(fall);
                db.SaveChanges();
            }
        }
コード例 #10
0
        //private static Project_Db_Context db ;

        #region Report functions
        public void AddReport(Report report)
        {
            var ToAdd = GetReport(report.id);

            if (ToAdd != null)
            {
                throw new Exception("An Assessment with an identical id already exists...");
            }
            using (var db = new Project_Db_Context())
            {
                try
                {
                    AddLocation(report.location);
                    db.Reports.Add(report);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.InnerException.Message);
                }
            }
        }