|
@@ -12,11 +12,15 @@ namespace AvaloniaApplication5.ViewModels
|
|
|
{
|
|
|
internal class ShowViewModel : ViewModelBase
|
|
|
{
|
|
|
- public List<Teacher> TeacherList => MainWindowViewModel.myConnection.Teachers.
|
|
|
+ List<Teacher> _teacherList;
|
|
|
+ public List<Teacher> TeacherList { get => _teacherList; set=> this.RaiseAndSetIfChanged(ref _teacherList, value); }
|
|
|
+ public ShowViewModel()
|
|
|
+ {
|
|
|
+ TeacherList = MainWindowViewModel.myConnection.Teachers.
|
|
|
Include(x => x.Gender).
|
|
|
Include(x => x.TeacherDisciplines).ThenInclude(x => x.Discipline).
|
|
|
- Include(x => x.TeacherCourses).ThenInclude(x => x.Course).
|
|
|
- ToList();
|
|
|
+ Include(x => x.TeacherCourses).ThenInclude(x => x.Course).ToList();
|
|
|
+ }
|
|
|
public void ToAddPage()
|
|
|
{
|
|
|
MainWindowViewModel.Instance.PageContent = new AddPage();
|
|
@@ -56,5 +60,152 @@ namespace AvaloniaApplication5.ViewModels
|
|
|
{
|
|
|
MainWindowViewModel.Instance.PageContent = new AddPage(idt);
|
|
|
}
|
|
|
+ public bool _genderm = false;
|
|
|
+ public bool Genderm
|
|
|
+ {
|
|
|
+ get => _genderm;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _genderm = value;
|
|
|
+ AllFilters();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool _genderg = false;
|
|
|
+ public bool Genderg
|
|
|
+ {
|
|
|
+ get => _genderg;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _genderg = value;
|
|
|
+ AllFilters();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ string _searchTeacher;
|
|
|
+ public string SearchTeacher
|
|
|
+ {
|
|
|
+ get => _searchTeacher;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _searchTeacher = value;
|
|
|
+ AllFilters();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ bool _checkTeacher = false;
|
|
|
+ public bool CheckTeacher
|
|
|
+ {
|
|
|
+ get => _checkTeacher;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _checkTeacher = value;
|
|
|
+ AllFilters();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ bool _phone = false;
|
|
|
+ public bool Phone
|
|
|
+ {
|
|
|
+ get => _phone;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _phone = value;
|
|
|
+ AllFilters();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Discipline> _disciplinesfilter = [new Discipline() { Id = 0, Name = "Âñå äèñöèïëèíû" }, .. MainWindowViewModel.myConnection.Disciplines.ToList()];
|
|
|
+ public List<Discipline> DisciplinesFilter { get => _disciplinesfilter; }
|
|
|
+ Discipline _selecteddiscipline = null;
|
|
|
+ public Discipline SelectedDiscipline
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (_selecteddiscipline == null) return _disciplinesfilter[0];
|
|
|
+ else { return _selecteddiscipline; }
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _selecteddiscipline = value;
|
|
|
+ AllFilters();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int _selectedSort = 0;
|
|
|
+ bool _Visible = false;
|
|
|
+ bool _Up = true;
|
|
|
+ bool _Down = true;
|
|
|
+
|
|
|
+ public int SelectedSort { get => _selectedSort; set { _selectedSort = value; AllFilters(); } }
|
|
|
+ public bool Visible { get => _Visible; set => this.RaiseAndSetIfChanged(ref _Visible, value); }
|
|
|
+ public bool Up { get => _Up; set { this.RaiseAndSetIfChanged(ref _Up, value); AllFilters(); } }
|
|
|
+ public bool Down { get => _Down; set { this.RaiseAndSetIfChanged(ref _Down, value); AllFilters(); } }
|
|
|
+ void AllFilters()
|
|
|
+ {
|
|
|
+ TeacherList = MainWindowViewModel.myConnection.Teachers.
|
|
|
+ Include(x => x.Gender).
|
|
|
+ Include(x => x.TeacherDisciplines).ThenInclude(x => x.Discipline).
|
|
|
+ Include(x => x.TeacherCourses).ThenInclude(x => x.Course).
|
|
|
+ ToList();
|
|
|
+ if (!string.IsNullOrEmpty(_searchTeacher)) {
|
|
|
+ TeacherList = TeacherList.Where(x => x.FIO.ToLower().Contains(_searchTeacher.ToLower())).ToList();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_genderm || _genderg)
|
|
|
+ {
|
|
|
+ TeacherList = TeacherList.Where(x => (_genderm && x.GenderId ==1)|| (_genderg && x.GenderId == 2)).ToList();
|
|
|
+
|
|
|
+ }
|
|
|
+ if (_phone)
|
|
|
+ {
|
|
|
+ TeacherList = TeacherList.Where(x => x.Phone == "").ToList();
|
|
|
+
|
|
|
+ }
|
|
|
+ if (_selecteddiscipline != null && _selecteddiscipline.Id != 0)
|
|
|
+ {
|
|
|
+ TeacherList = TeacherList.Where(x => x.TeacherDisciplines.Any(y => y.Discipline.Id == _selecteddiscipline.Id)).ToList();
|
|
|
+ }
|
|
|
+ switch (_selectedSort)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ Visible = false;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ Visible = true;
|
|
|
+ if (_Down)
|
|
|
+ {
|
|
|
+ TeacherList = TeacherList.OrderByDescending(x => x.Experience).ToList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TeacherList = TeacherList.OrderBy(x => x.Experience).ToList();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ Visible = true;
|
|
|
+ if (_Down)
|
|
|
+ {
|
|
|
+
|
|
|
+ TeacherList = TeacherList.OrderByDescending(x => x.LastName).ToList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TeacherList = TeacherList.OrderBy(x => x.LastName).ToList();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ Visible = true;
|
|
|
+ if (_Down)
|
|
|
+ {
|
|
|
+ TeacherList = TeacherList.OrderByDescending(x => x.summa).ToList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TeacherList = TeacherList.OrderBy(x => x.summa).ToList();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|