|
@@ -1,4 +1,5 @@
|
|
|
-using Microsoft.EntityFrameworkCore;
|
|
|
+using Avalonia.Media;
|
|
|
+using Microsoft.EntityFrameworkCore;
|
|
|
using ReactiveUI;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -17,16 +18,7 @@ namespace WorkWithDatabase.ViewModels
|
|
|
}
|
|
|
|
|
|
Teacher? _newTeaher;
|
|
|
-
|
|
|
- List<TeacherCourse> _courseTable;
|
|
|
- List<TeacherSubject> _subjectTable;
|
|
|
-
|
|
|
- public List<TeacherCourse> CourseTable { get => _courseTable; set => this.RaiseAndSetIfChanged(ref _courseTable, value); }
|
|
|
-
|
|
|
- public List<TeacherSubject> SubjectTable { get => _subjectTable; set => this.RaiseAndSetIfChanged(ref _subjectTable, value); }
|
|
|
-
|
|
|
public Teacher? NewTeaher { get => _newTeaher; set => this.RaiseAndSetIfChanged(ref _newTeaher, value); }
|
|
|
-
|
|
|
|
|
|
public PageAddTeacherVM()
|
|
|
{
|
|
@@ -42,5 +34,47 @@ namespace WorkWithDatabase.ViewModels
|
|
|
CourseTable = NewTeaher.TeacherCourses.ToList();
|
|
|
SubjectTable = NewTeaher.TeacherSubjects.ToList();
|
|
|
}
|
|
|
+
|
|
|
+ public List<Gender> Genders => MainWindowViewModel.myConnection.Genders.ToList();
|
|
|
+ public List<Subject> Subjects => MainWindowViewModel.myConnection.Subjects.ToList().Except(_newTeaher.TeacherSubjects.Select(x => x.SubjectNavigation)).ToList();
|
|
|
+ public List<Course> Courses => MainWindowViewModel.myConnection.Courses.ToList().Except(_newTeaher.TeacherCourses.Select(x => x.CourseNavigation)).ToList();
|
|
|
+
|
|
|
+ List<TeacherCourse>? _courseTable;
|
|
|
+ public List<TeacherCourse>? CourseTable { get => _courseTable; set => this.RaiseAndSetIfChanged(ref _courseTable, value); }
|
|
|
+ List<TeacherSubject>? _subjectTable;
|
|
|
+ public List<TeacherSubject>? SubjectTable { get => _subjectTable; set => this.RaiseAndSetIfChanged(ref _subjectTable, value); }
|
|
|
+
|
|
|
+ Course? selectedCourse;
|
|
|
+ Subject? selectedSubject;
|
|
|
+
|
|
|
+ public Course? SelectedCourse
|
|
|
+ {
|
|
|
+ get => null;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ if (value != null)
|
|
|
+ {
|
|
|
+ NewTeaher.TeacherCourses.Add(new TeacherCourse() { TeacherNavigation = NewTeaher, CourseNavigation = value });
|
|
|
+ CourseTable = NewTeaher.TeacherCourses.ToList();
|
|
|
+ this.RaisePropertyChanged(nameof(Courses));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Subject? SelectedSubject
|
|
|
+ {
|
|
|
+ get => null;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ if (value != null)
|
|
|
+ {
|
|
|
+ NewTeaher.TeacherSubjects.Add(new TeacherSubject() { TeacherNavigation = NewTeaher, SubjectNavigation = value });
|
|
|
+ SubjectTable = NewTeaher.TeacherSubjects.ToList();
|
|
|
+ this.RaisePropertyChanged(nameof(Subjects));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|