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

                context.Exams.Add(exam);
                context.SaveChanges();
            }
        }
Example #2
0
        public ExamProperties(ScheduleRepository sRepo, SessionRepository repo, int examToUpdateId, ExamPropertiesMode mode)
        {
            InitializeComponent();

            _sRepo = sRepo;
            _repo = repo;
            _examId = examToUpdateId;
            _mode = mode;

            if (_mode == ExamPropertiesMode.Edit)
            {
                _exam = _repo.GetExam(_examId);
            }

            if (_mode == ExamPropertiesMode.New)
            {
                _exam = new Exam();
            }
        }
Example #3
0
        private void Save_Click(object sender, EventArgs e)
        {
            var newExam = new Exam() { ExamId = _exam.ExamId, DisciplineId = _exam.DisciplineId, IsActive = true };

            newExam.ConsultationDateTime = ConsDate.Value;
            var consAud = _sRepo.FindAuditorium(ConsAudBox.Text);
            if (consAud != null)
            {
                newExam.ConsultationAuditoriumId = consAud.AuditoriumId;
            }

            newExam.ExamDateTime = ExamDate.Value;
            var examAud = _sRepo.FindAuditorium(ExamAudBox.Text);
            if (examAud != null)
            {
                newExam.ExamAuditoriumId = examAud.AuditoriumId;
            }

            _repo.UpdateExam(newExam);

            Close();
        }
Example #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();
            }
        }
Example #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();
            }
        }