private async void btn_DeleteLesson_Lessons_Click(object sender, RoutedEventArgs e)
 {
     if (await delete_lessons() == ContentDialogResult.Secondary)
     {
         LessonManager.DeleteLesson((selected_listview.SelectedItem as Lesson).day, (selected_listview.SelectedItem as Lesson).lesson_time);
         Frame.Navigate(this.GetType());
         Frame.GoBack();
     }
 }
        public TransactionObject DeleteLesson(int lessonID)
        {
            TransactionObject response = new TransactionObject();

            try
            {
                lessonManager.DeleteLesson(lessonManager.GetLesson(lessonID));
                uow.Save();
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess   = false;
                response.Explanation = base.GetExceptionMessage(ex);
            }
            return(response);
        }
        private async void btn_Done_AddLesson_Click(object sender, RoutedEventArgs e)
        {
            bool       cont                = true;
            int        daynumber           = cmb_Day_AddLesson.SelectedIndex;
            DayOfWeek  day                 = DayOfWeek.Monday;
            bool       day_complete        = true;
            LessonTime lessontime          = LessonTimeManager.GetLessonTimes()[0];
            bool       lessontime_complete = true;
            Subject    subject             = SubjectManager.GetSubjects()[0];
            bool       subject_complete    = true;

            if (daynumber == 0)
            {
                day = DayOfWeek.Monday;
            }
            else if (daynumber == 1)
            {
                day = DayOfWeek.Tuesday;
            }
            else if (daynumber == 2)
            {
                day = DayOfWeek.Wednesday;
            }
            else if (daynumber == 3)
            {
                day = DayOfWeek.Thursday;
            }
            else if (daynumber == 4)
            {
                day = DayOfWeek.Friday;
            }
            else
            {
                day_complete = false;
            }

            if (cmb_LessonTime_AddLesson.SelectedIndex != -1)
            {
                lessontime = (LessonTime)cmb_LessonTime_AddLesson.SelectedItem;
            }
            else
            {
                lessontime_complete = false;
            }

            if (cmb_Subject_AddLesson.SelectedIndex != -1)
            {
                subject = (Subject)cmb_Subject_AddLesson.SelectedItem;
            }
            else
            {
                subject_complete = false;
            }

            if (day_complete == false || lessontime_complete == false || subject_complete == false)
            {
                LessonManager.not_completed_dialog();
            }
            else
            {
                if (LessonManager.GetLesson(day, lessontime) != null)
                {
                    ContentDialogResult result = await LessonManager.already_exists_dialog();

                    if (result == ContentDialogResult.Secondary)
                    {
                        edit_lesson = LessonManager.GetLesson(day, lessontime);
                    }
                    else
                    {
                        cont = false;
                    }
                }
                if (cont)
                {
                    if (edit_lesson != null)
                    {
                        LessonManager.DeleteLesson(edit_lesson.day, edit_lesson.lesson_time);
                    }
                    LessonManager.AddLesson(new Lesson {
                        day = day, lesson_time = lessontime, subject_id = subject.id
                    });
                }
            }
            if (cont)
            {
                Frame.GoBack();
            }
        }