public void Initialize(Person connectedPerson) { ConnectedPerson = connectedPerson; ResetAll(); if (HasRequiredPermissions) { // Get the school data and use to it to populate this View Model's data SchoolEntities schoolData = new SchoolEntities(); // Create a list of all the classes in the school schoolData.Classes.ToList().ForEach(currClass => AvailableClasses.Add(currClass.classID, currClass.className)); AvailableHomeroomClasses.Add(FIELD_NOT_SET, "לא מוגדר"); schoolData.Classes.Where(currClass => currClass.Teachers.Count() == 0).ToList() .ForEach(currClass => AvailableHomeroomClasses.Add(currClass.classID, currClass.className)); // Create a list of all the parents in the school AvailableParents.Add(FIELD_NOT_SET, "לא מוגדר"); schoolData.Persons.Where(p => p.isParent).ToList() .ForEach(parent => AvailableParents.Add(parent.personID, parent.firstName + " " + parent.lastName)); // Create a list of all the students in the school schoolData.Persons.Where(p => p.isStudent).ToList() .ForEach(student => AvailableStudents.Add(student.personID, student.firstName + " " + student.lastName)); // Create a list of all the courses in the school schoolData.Courses.Where(course => course.isHomeroomTeacherOnly == false).ToList() .ForEach(course => AvailableCoursesMustChoose.Add(course.courseID, course.courseName)); AvailableCourses.Add(FIELD_NOT_SET, "לא מוגדר"); AvailableCoursesMustChoose.ToList().ForEach(course => AvailableCourses.Add(course.Key, course.Value)); } }
public void Initialize(Person connectedPerson) { // Reset all information ConnectedPerson = connectedPerson; AvailableUserTypes.Clear(); AvailableUsers.Clear(); AvailableClasses.Clear(); AvailableParents.Clear(); AvailableStudents.Clear(); AvailableCourses.Clear(); AvailableCoursesMustChoose.Clear(); AvailableHomeroomClasses.Clear(); if (HasRequiredPermissions) { _schoolData = new SchoolEntities(); // Create a list of all the editable user types if (!CanEditManagement) { AvailableUserTypes.AddRange(new List <string>() { Globals.USER_TYPE_STUDENT, Globals.USER_TYPE_TEACHERS, Globals.USER_TYPE_PARENTS }); } else { AvailableUserTypes.AddRange(new List <string>() { Globals.USER_TYPE_STUDENT, Globals.USER_TYPE_TEACHERS, Globals.USER_TYPE_PARENTS, Globals.USER_TYPE_SECRETARIES, Globals.USER_TYPE_PRINCIPAL }); } SelectedUserType = AvailableUserTypes[0]; // Create a list of all the classes in the school _schoolData.Classes.ToList().ForEach(currClass => AvailableClasses.Add(currClass.classID, currClass.className)); AvailableHomeroomClasses.Add(FIELD_NOT_SET, "לא מוגדר"); _schoolData.Classes.Where(currClass => currClass.Teachers.Count() == 0).ToList() .ForEach(currClass => AvailableHomeroomClasses.Add(currClass.classID, currClass.className)); // Create a list of all the parents in the school AvailableParents.Add(FIELD_NOT_SET, "לא מוגדר"); _schoolData.Persons.Where(p => p.isParent).ToList() .ForEach(parent => AvailableParents.Add(parent.personID, parent.firstName + " " + parent.lastName)); // Create a list of all the students in the school _schoolData.Persons.Where(p => p.isStudent).ToList() .ForEach(student => AvailableStudents.Add(student.personID, student.firstName + " " + student.lastName)); // Create a list of all the courses in the school _schoolData.Courses.Where(course => course.isHomeroomTeacherOnly == false).ToList() .ForEach(course => AvailableCoursesMustChoose.Add(course.courseID, course.courseName)); AvailableCourses.Add(FIELD_NOT_SET, "לא מוגדר"); AvailableCoursesMustChoose.ToList().ForEach(course => AvailableCourses.Add(course.Key, course.Value)); } }