public void Initialize(Person connectedPerson) { ConnectedPerson = connectedPerson; // Get the list of existing classes ClassesTableData = new ObservableCollection <ClassData>(_schoolData.Classes.AsEnumerable().Select(currClass => ModelClassToClassData(currClass)).ToList()); // Create the basic list of available classes AvailableTeachers.Clear(); // Add a 'No teacher' option, as not all classes have a teacher assigned to them. AvailableTeachers.Add(NOT_ASSIGNED, "אין מורה משויך"); // Create the list of teachers that are not homeroom teachers already. _schoolData.Teachers.Where(teacher => teacher.classID == null && !teacher.Person.User.isDisabled).ToList() .ForEach(teacher => AvailableTeachers.Add(teacher.teacherID, teacher.Person.firstName + " " + teacher.Person.lastName)); // Create the basic list of available rooms AvailableRooms.Clear(); // Add a 'no room' option, as not all classes have an an assigned room. AvailableRooms.Add(NOT_ASSIGNED, "אין חדר משויך"); // Create the list of rooms that are not assigned to a specific class already _schoolData.Rooms.Where(room => room.Classes.Count() == 0).ToList() .ForEach(room => AvailableRooms.Add(room.roomID, room.roomName)); // Reset selections SelectedTeacher = NOT_ASSIGNED; SelectedRoom = NOT_ASSIGNED; // For some reason, after re-initializing this view, the selections are not updated properly in the view unless called again OnPropertyChanged("SelectedTeacher"); OnPropertyChanged("SelectedRoom"); }
/// <summary> /// Assistant method that clears all the ViewModel properties /// </summary> private void ResetData() { AvailableSearchChoices.Clear(); LessonsTableData.Clear(); AvailableClasses.Clear(); AvailableCourses.Clear(); AvailableTeachers.Clear(); AvailableRooms.Clear(); SelectedLesson = null; SelectedSearchChoice = NOT_ASSIGNED; SelectedTeacher = NOT_ASSIGNED; SelectedClass = NOT_ASSIGNED; LessonFirstDay = NOT_ASSIGNED; LessonSecondDay = NOT_ASSIGNED; LessonThirdDay = NOT_ASSIGNED; LessonFourthDay = NOT_ASSIGNED; LessonFirstHour = NOT_ASSIGNED; LessonSecondHour = NOT_ASSIGNED; LessonThirdHour = NOT_ASSIGNED; LessonFourthHour = NOT_ASSIGNED; }