コード例 #1
0
        public void AddExam(Exam exam)
        {
            using (var context = new SessionContext(ConnectionString))
            {
                exam.ExamId = 0;

                context.Exams.Add(exam);
                context.SaveChanges();
            }
        }
コード例 #2
0
        public void AddExamsRange(IEnumerable<Exam> examList)
        {
            using (var context = new SessionContext(ConnectionString))
            {
                foreach (var exam in examList)
                {
                    exam.ExamId = 0;
                    context.Exams.Add(exam);
                }

                context.SaveChanges();
            }
        }
コード例 #3
0
        private void RemoveLogEvent(int logEventId)
        {
            using (var context = new SessionContext(ConnectionString))
            {
                var logEvent = context.EventLog.FirstOrDefault(le => le.LogEventId == logEventId);

                context.EventLog.Remove(logEvent);
                context.SaveChanges();
            }
        }
コード例 #4
0
        public void UpdateExamWOLog(Exam exam)
        {
            using (var context = new SessionContext(ConnectionString))
            {
                var curExam = GetExam(exam.ExamId);

                curExam.ConsultationAuditoriumId = exam.ConsultationAuditoriumId;
                curExam.ConsultationDateTime = exam.ConsultationDateTime;
                curExam.DisciplineId = exam.DisciplineId;
                curExam.ExamAuditoriumId = exam.ExamAuditoriumId;
                curExam.ExamDateTime = exam.ExamDateTime;
                curExam.ExamId = exam.ExamId;
                curExam.IsActive = exam.IsActive;

                context.SaveChanges();
            }
        }
コード例 #5
0
        public void UpdateExam(Exam exam)
        {
            using (var context = new SessionContext(ConnectionString))
            {
                var oldExam = context.Exams.FirstOrDefault(e => e.ExamId == exam.ExamId);
                oldExam.IsActive = false;

                exam.ExamId = 0;

                context.Exams.Add(exam);
                context.SaveChanges();

                var logEntry = new LogEvent() { OldExam = oldExam, NewExam = exam, DateTime = DateTime.Now };

                context.EventLog.Add(logEntry);
                context.SaveChanges();
            }
        }
コード例 #6
0
 public void SaveChanges()
 {
     using (var context = new SessionContext(ConnectionString))
     {
         context.SaveChanges();
     }
 }
コード例 #7
0
        public void RemoveExam(int examId)
        {
            using (var context = new SessionContext(ConnectionString))
            {
                var exam = context.Exams.FirstOrDefault(e => e.ExamId == examId);

                context.Exams.Remove(exam);
                try
                {
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    throw;
                }
            }
        }