public void UpdateLogEvent(LogEvent logEvent)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                var curLogEvent = context.EventLog.FirstOrDefault(le => le.LogEventId == logEvent.LogEventId);

                curLogEvent.DateTime = logEvent.DateTime;
                curLogEvent.OldExam = context.Exams.FirstOrDefault(e => e.ExamId == logEvent.OldExam.ExamId);
                curLogEvent.NewExam = context.Exams.FirstOrDefault(e => e.ExamId == logEvent.NewExam.ExamId);

                context.SaveChanges();
            }
        }
        public LogEvent AddLogEvent(LogEvent logEvent)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                logEvent.OldExam = context.Exams.FirstOrDefault(e => e.ExamId == logEvent.OldExam.ExamId);
                logEvent.NewExam = context.Exams.FirstOrDefault(e => e.ExamId == logEvent.NewExam.ExamId);

                context.EventLog.Add(logEvent);
                context.SaveChanges();

                return logEvent;
            }
        }
        public void UpdateExam(Exam exam)
        {
            using (var context = new ScheduleContext(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();
            }
        }