Пример #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();
        }
Пример #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();
        }
Пример #3
0
        public IEnumerable <Subjects> GetAllSubjects()
        {
            ISubjectsRepository             repo           = new SubjectsRepository(getEntities());
            IEnumerable <Entities.Subjects> returnedValue  = repo.GetAll();
            IEnumerable <Subjects>          returnedValue2 = Mapper.Map <IEnumerable <Entities.Subjects>, IEnumerable <Subjects> >(returnedValue);

            return(returnedValue2);
        }
Пример #4
0
        private void subjectDeleteButton_Click(object sender, EventArgs e)
        {
            var selectedRowIndex = GetSelectedRowIndex(subjectDataGridView);

            if (selectedRowIndex == null)
            {
                return;
            }
            SubjectsRepository.Delete(SubjectsRepository.GetAll()[(int)selectedRowIndex].Id);
            UpdateSubjectsGrid();
        }
Пример #5
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();
Пример #6
0
 private void UpdateSubjectsGrid()
 {
     subjectDataGridView.Rows.Clear();
     SubjectsRepository.GetAll().ForEach(subject => subjectDataGridView.Rows.Add(subject.Name, subject.Faculty));
 }