public void AddExam(Exam exam) { using (var context = new SessionContext(ConnectionString)) { exam.ExamId = 0; context.Exams.Add(exam); context.SaveChanges(); } }
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(); } }
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(); } }
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(); } }
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(); } }
public void SaveChanges() { using (var context = new SessionContext(ConnectionString)) { context.SaveChanges(); } }
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; } } }