/// <summary> /// Updates the LessonsTableData with the lessons of the SelectedSearchChoice /// </summary> private void UseSelectedSearchChoice() { if (SelectedSearchChoice != NOT_ASSIGNED) { // Clean lessons table before adding items to it LessonsTableData.Clear(); // Check which category the search choice is from, and fill the LessonsTableData with the relevent lessons if (SearchingByClass) { // Find the class that was chosen, and get its lessons _schoolData.Classes.Find(SelectedSearchChoice).Lessons.ToList(). ForEach(lesson => LessonsTableData.Add(ModelLessonToLessonData(lesson))); } else if (SearchingByCourse) { // Find the course that was chosen, and get its lessons _schoolData.Courses.Find(SelectedSearchChoice).Lessons.ToList(). ForEach(lesson => LessonsTableData.Add(ModelLessonToLessonData(lesson))); } else if (SearchingByTeacher) { // Find the teacher that was chosen, and get his/hers lessons _schoolData.Teachers.Find(SelectedSearchChoice).Lessons.ToList(). ForEach(lesson => LessonsTableData.Add(ModelLessonToLessonData(lesson))); } else { // Unknown search category - don't show any lesson } } }
/// <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; }