private async void ViewList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ViewList.SelectedItem == null)
            {
                return;
            }

            // Get selected teacher first
            ETeacherEntry SelectedTeacher = null;

            foreach (var x in CourseTeachers.lists)
            {
                if (x.GetView == (ViewList.SelectedItem))
                {
                    SelectedTeacher = x;
                    break;
                }
            }

            // Unselect the selected item, it will again call this function but null check return it
            ViewList.SelectedItem = null;

            // Content Dialog that will be displayed
            ContentDialog contentDialog = new ContentDialog()
            {
                PrimaryButtonText = "Remove from this course",
                CloseButtonText   = "Ok",
                Title             = SelectedTeacher.Name,
                Content           =
                    new TextBlock()
                {
                    Text = string.Format(
                        "{0}\n\n" +
                        "Phone   \t:\t{1}, {2}\n" +
                        "Email   \t:\t{3}, {4}\n" +
                        "Website \t:\t{5}\n" +
                        "Other Info :\t{6}",
                        SelectedTeacher.Address,
                        SelectedTeacher.Phone[0],
                        SelectedTeacher.Phone[1],
                        SelectedTeacher.Email[0],
                        SelectedTeacher.Email[1],
                        SelectedTeacher.Website,
                        SelectedTeacher.OtherInfo),
                    IsTextSelectionEnabled = true
                }
            };

            switch (await contentDialog.ShowAsync())
            {
            // Delete
            case ContentDialogResult.Primary:
                ViewList.Items.Remove(SelectedTeacher.GetView);
                CourseTeachers.lists.Remove(SelectedTeacher);
                SelectedTeacher.DestroyTeacherViews();
                SelectedCourse.RemoveTeacherFromCourse(SelectedTeacher);
                HDDSync.SaveSelectedCourse();
                break;
            }
        }
Esempio n. 2
0
 public override void PostDeleteTasks(ETeacherEntry element)
 {
     foreach (CourseEntry s in AllCourses.Instance.CoursesList)
     {
         s.RemoveTeacherFromCourse(element);
     }
     HDDSync.SaveTeachersToHdd();
 }
Esempio n. 3
0
 public override void PreDeleteTasks(ETeacherEntry element, out bool ToDelete)
 {
     ToDelete = true;
     foreach (CourseEntry e in AllCourses.Instance.lists)
     {
         if (e.IC == element)
         {
             ToDelete = false;
             break;
         }
     }
 }
Esempio n. 4
0
        public override void PostModifyTasks(ETeacherEntry entry)
        {
            foreach (CourseEntry course in AllCourses.Instance.lists)
            {
                if (course.TeacherEntry.lists.Contains(entry) || course.IC == entry)
                {
                    HDDSync.SaveCourseToHdd(course);
                }
            }

            HDDSync.SaveTeachersToHdd();
        }
Esempio n. 5
0
 public override void PostAddTasks(ETeacherEntry element)
 {
     HDDSync.SaveTeachersToHdd();
 }