Example #1
0
        private void teacherEditButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(teachersDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            var teacher   = TeachersRepository.GetAll()[(int)selectedRowIndex];
            var teacherVM = new TeacherVM
            {
                Teacher    = teacher,
                SubjectIds = TeacherSubjectRepository.GetSubjectsForTeacher(teacher.Id),
            };

            new DetailedTeacherForm
            (
                teacherVM,
                SubjectsRepository.GetAll(),
                updatedTeacherVM =>
            {
                TeachersRepository.Update(updatedTeacherVM.Teacher);
                TeacherSubjectRepository.UpdateSubjectsForTeacher(updatedTeacherVM.Teacher.Id, updatedTeacherVM.SubjectIds);
                UpdateTeachersGrid();
                return(true);
            }
            ).Show();
        }
Example #2
0
        private void subjectEditButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(subjectDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            var subject   = SubjectsRepository.GetAll()[(int)selectedRowIndex];
            var subjectVM = new SubjectVM
            {
                Subject    = subject,
                TeacherIds = TeacherSubjectRepository.GetTeachersForSubject(subject.Id),
            };

            new DetailedSubjectForm
            (
                subjectVM,
                TeachersRepository.GetAll(),
                updatedSubjectVM =>
            {
                SubjectsRepository.Update(updatedSubjectVM.Subject);
                TeacherSubjectRepository.UpdateTeachersForSubject(updatedSubjectVM.Subject.Id, updatedSubjectVM.TeacherIds);
                UpdateSubjectsGrid();
                return(true);
            }
            ).Show();
        }
Example #3
0
 private void subjectCreateButton_Click(object sender, EventArgs e) => new DetailedSubjectForm
 (
     null,
     TeachersRepository.GetAll(),
     newSubjectVM =>
 {
     var newSubjectId = SubjectsRepository.Add(newSubjectVM.Subject).Id;
     TeacherSubjectRepository.AddTeachersForSubject(newSubjectId, newSubjectVM.TeacherIds);
     UpdateSubjectsGrid();
     return(true);
 }
 ).Show();
Example #4
0
 private void teacherCreateButton_Click(object sender, EventArgs e) => new DetailedTeacherForm
 (
     null,
     SubjectsRepository.GetAll(),
     newTeacherVM =>
 {
     var newTeacherId = TeachersRepository.Add(newTeacherVM.Teacher).Id;
     TeacherSubjectRepository.AddSubjectsForTeacher(newTeacherId, newTeacherVM.SubjectIds);
     UpdateTeachersGrid();
     return(true);
 }
 ).Show();
Example #5
0
 public UnitOfWork(ELearningDBContext context)
 {
     _context = context;
     Account  = new AccountRepository(_context);
     Comments = new CommentRepository(_context);
     Courses  = new CourseRepository(_context);
     // CourseSubject = new CourseSubjectRepository(_context);
     Documents       = new DocumentRepository(_context);
     Lectures        = new LectureRepository(_context);
     Rating          = new RatingRepository(_context);
     Role            = new RoleRepository(_context);
     StudentSubjects = new StudentSubjectRepository(_context);
     StudentTests    = new StudentTestRepository(_context);
     Subjects        = new SubjectRepository(_context);
     TeacherSubjects = new TeacherSubjectRepository(_context);
 }
 public TeacherSubjectViewModel(TeacherSubjectRepository repository, IFileRecordService <TeacherSubject> service)
 {
     this.repository = repository ?? throw new NullReferenceException();
     this.service    = service ?? throw new NullReferenceException();
     UpdateCollection();
 }