public MainTeacherCuratorViewModel() { DbContext = new DataBaseContext(); var currentUserLogin = Properties.Settings.Default.UserName; Department = DbContext.Persons.FirstOrDefault(x => x.User.Login == currentUserLogin).Department; int comparingYear = GetCompareYear(); Groups = DbContext.Groups.Where(x => x.DepartmentId == Department.Id && x.Year == comparingYear).ToList(); SelectedGroupCommand = new DelegateCommand(SelectGroup); SelectedStudentCommand = new DelegateCommand(SelectStudent); ExportCommand = new DelegateCommand(Export); AddStudentVM = new AddStudentViewModel(); StudentVisible = Visibility.Hidden; IsImportExporvVisible = Visibility.Hidden; IsAddStudentEnable = false; }
private void SelectGroup() { if (SelectedGroup != null) { var currentPerson = DbContext.Persons.FirstOrDefault(x => x.User.Login == Properties.Settings.Default.UserName); if (currentPerson != null && SelectedGroup.СuratorId == currentPerson.Id) { IsAddStudentEnable = true; IsImportExporvVisible = Visibility.Visible; } else { IsAddStudentEnable = false; IsImportExporvVisible = Visibility.Hidden; } AddStudentVM = new AddStudentViewModel(); StudentVisible = Visibility.Hidden; SelectedStudent = null; Depersonilize dep = new Depersonilize(); Students = dep.Undepersonilized(DbContext.Students.ToList()).Where(x => x.GroupId == SelectedGroup.Id).ToList(); } }