private async void OnRemoveFaculty() { var facultySpecialities = await _sRepo.GetFilteredSpecialtiesAsync(s => s.FacultyId == SelectedFaculty.FacultyId); if (facultySpecialities.Count > 0) { var result = MessageBox.Show( "Вы точно хотите удалить факультет вместе с прикреплёнными специальностями и студентами?", "К этому факультету прикреплены специальности.", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: break; case MessageBoxResult.No: return; default: return; } } await _repo.DeleteFacultyWithSpecialitiesAndStudentsAsync(SelectedFaculty.FacultyId); var faculty = Faculties.FirstOrDefault(f => f.FacultyId == SelectedFaculty.FacultyId); if (faculty != null) { Faculties.Remove(faculty); } }
private BaseApplication MapToApplication(InputModel inputModel) { var fac = Faculties.FirstOrDefault(x => x.FacultyId == inputModel.FacultyId); var lec = Lecterns.FirstOrDefault(x => x.LecternId == inputModel.LecternId); var application = new BaseApplication { Email = inputModel.Email, Password = inputModel.Password, UserType = inputModel.UserType, DocNo = inputModel.DocNo, FirstName = inputModel.FirstName, SecondName = inputModel.SecondName, Faculty = Faculties.FirstOrDefault(x => x.FacultyId == inputModel.FacultyId), Lectern = Lecterns.FirstOrDefault(x => x.LecternId == inputModel.LecternId), CreatedAt = DateTime.Now }; if (inputModel.UserType == UserType.Student) { application.UserType = UserType.Student; application.DegreeType = inputModel.DegreeType; application.Curriculum = Curriculums.FirstOrDefault(x => x.CurriculumId == inputModel.CurriculumId); application.YearNo = inputModel.YearNo; } else { application.UserType = UserType.Lecturer; application.DegreeType = DegreeType.Unknown; application.Curriculum = null; } return(application); }
private async void OnUpdateFaculty() { var result = await _repo.UpdateFacultyAsync(SelectedFaculty); var faculty = Faculties.FirstOrDefault(f => f.FacultyId == SelectedFaculty.FacultyId); faculty.CopyProperties(SelectedFaculty); }
private async void OnUpdateSpecialty() { SelectedSpeciality.Faculty = Faculties.FirstOrDefault(f => f.FacultyId == SelectedSpeciality.FacultyId); var result = await _repo.UpdateSpecialtyAsync(SelectedSpeciality); var specialty = Specialities.FirstOrDefault(s => s.SpecialtyId == SelectedSpeciality.SpecialtyId); specialty.CopyProperties(SelectedSpeciality); }
//Заполнение всех списков значениями private async void GetTables() => await Task.Run(() => { Organizations = (List <Organization>)NirsSystem.GetListObject <Organization>(); if (Organizations == null) { Organizations = new List <Organization>(); } Organizations.Insert(0, new Organization { OrganizationId = 0, OrganizationName = "(пусто)" }); SelectedOrganization = Organizations.FirstOrDefault(u => u.OrganizationId == _author.OrganizationId); OnPropertyChanged("Organizations"); OnPropertyChanged("SelectedOrganization"); Faculties = (List <Faculty>)NirsSystem.GetListObject <Faculty>(); if (Faculties == null) { Faculties = new List <Faculty>(); } Faculties.Insert(0, new Faculty { FacultyId = 0, FacultyName = "(пусто)" }); SelectedFaculty = Faculties.FirstOrDefault(u => u.FacultyId == _author.FacultyId); OnPropertyChanged("Faculties"); OnPropertyChanged("SelectedFaculty"); Departments = (List <Department>)NirsSystem.GetListObject <Department>(); if (Departments == null) { Departments = new List <Department>(); } Departments.Insert(0, new Department { DepartmentId = 0, DepartmentName = "(пусто)" }); SelectedDepartment = Departments.FirstOrDefault(u => u.DepartmentId == _author.DepartmentId); OnPropertyChanged("Departments"); OnPropertyChanged("SelectedDepartment"); Groups = (List <Group>)NirsSystem.GetListObject <Group>(); if (Groups == null) { Groups = new List <Group>(); } Groups.Insert(0, new Group { GroupId = 0, GroupName = "(пусто)" }); SelectedGroup = Groups.FirstOrDefault(u => u.GroupId == _author.GroupId); OnPropertyChanged("Groups"); OnPropertyChanged("SelectedGroup"); Positions = (List <Position>)NirsSystem.GetListObject <Position>(); if (Positions == null) { Positions = new List <Position>(); } Positions.Insert(0, new Position { PositionId = 0, PositionName = "(пусто)" }); SelectedPosition = Positions.FirstOrDefault(u => u.PositionId == _author.PositionId); OnPropertyChanged("Positions"); OnPropertyChanged("SelectedPosition"); AcademicDegrees = (List <AcademicDegree>)NirsSystem.GetListObject <AcademicDegree>(); if (AcademicDegrees == null) { AcademicDegrees = new List <AcademicDegree>(); } AcademicDegrees.Insert(0, new AcademicDegree { AcademicDegreeId = 0, AcademicDegreeName = "(пусто)" }); SelectedAcademicDegree = AcademicDegrees.FirstOrDefault(u => u.AcademicDegreeId == _author.AcademicDegreeId); OnPropertyChanged("AcademicDegrees"); OnPropertyChanged("SelectedAcademicDegree"); });