async private void SubmitAddCourse_Tapped(object sender, TappedRoutedEventArgs e) { /* add course information to db with successful message popup*/ try { /*search database for all courses that haven't been deleted and also that there are no duplicate course names*/ classList = await completedCourses .Where(CoursesComplete => CoursesComplete.courseName == addCourseName.Text && CoursesComplete.courseRemoved == false) .ToCollectionAsync(); //Check to make sure course name selection is entered. if (selectCourseName.SelectedValue != null) { if (classList.Count == 0) { CoursesComplete addClass = new CoursesComplete { courseName = addCourseName.Text, courseNumber = addCourseNumber.Text, courseCredits = addCreditsReceived.Text, gradeReceived = addGrade.Text, quarterComplete = addQuarter.Text, instructorName = addInstructor.Text, courseRemoved = false }; await App.MobileService1.GetTable <CoursesComplete>().InsertAsync(addClass); var dialog = new MessageDialog("Class added successfully!"); await dialog.ShowAsync(); ClearAdd(); } else { var dialog = new MessageDialog("Class has already been entered."); await dialog.ShowAsync(); } } else { var dialog = new MessageDialog("Course Name not selected."); await dialog.ShowAsync(); } } catch (Exception em) { var dialog = new MessageDialog("An Error Occured: " + em.Message); await dialog.ShowAsync(); } }
async private void SubmitDeleteCourse_Tapped(object sender, TappedRoutedEventArgs e) { /*delete course information in db with successful message popup*/ try { //make sure a class is selected before submitting delete request if (deleteSelectedName.SelectedValue != null) { CoursesComplete deleteClass = new CoursesComplete { Id = deleteId.Text, courseName = deleteCourseName.Text, courseNumber = deleteCourseNumber.Text, courseCredits = deleteCreditsReceived.Text, gradeReceived = deleteGrade.Text, quarterComplete = deleteQuarter.Text, instructorName = deleteInstructor.Text, courseRemoved = true }; await completedCourses.UpdateAsync(deleteClass); var dialog = new MessageDialog("Class deleted successfully!"); await dialog.ShowAsync(); ClearDelete(); } else { var dialog = new MessageDialog("Class not selected for deletion."); await dialog.ShowAsync(); } } catch (Exception em) { var dialog = new MessageDialog("An Error Occured: " + em.Message); await dialog.ShowAsync(); } }