private async void Button_Clicked_1(object sender, EventArgs e) { var newCourse = new Course(); newCourse.CourseName = CourseName.Text; newCourse.StartDate = startDate.Date; newCourse.EndDate = endDate.Date; newCourse.Status = (string)CourseStatus.SelectedItem; newCourse.InstructorName = InstructorName.Text; newCourse.InstructorPhone = InstructorPhone.Text; newCourse.InstructorEmail = InstructorEmail.Text; newCourse.Notes = Notes.Text; newCourse.Term = _currentTerm.Id; if (FieldValidation.NullCheck(InstructorName.Text) && FieldValidation.NullCheck(InstructorPhone.Text) && FieldValidation.NullCheck(CourseName.Text)) { if (FieldValidation.EmailCheck(InstructorEmail.Text)) { if (newCourse.StartDate < newCourse.EndDate) { await _connection.InsertAsync(newCourse); await Navigation.PopModalAsync(); } else { await DisplayAlert("Warning", "Please make sure the start date is before the end date", "Ok"); } } else { await DisplayAlert("Warning", "Please make sure your email is valid before submitting", "Ok"); } } else { await DisplayAlert("Warning", "Please make sure all fields are filled in before submitting", "Ok"); } }
private async void Edit_Clicked(object sender, EventArgs e) { _currentCourse.CourseName = CourseName.Text; _currentCourse.StartDate = StartDate.Date; _currentCourse.EndDate = EndDate.Date; _currentCourse.Status = (string)CourseStatus.SelectedItem; _currentCourse.InstructorName = InstructorName.Text; _currentCourse.InstructorPhone = InstructorPhone.Text; _currentCourse.InstructorEmail = InstructorEmail.Text; _currentCourse.Notes = Notes.Text; _currentCourse.NotificationEnabled = EnableNotifications.On == true ? 1 : 0; if (FieldValidation.NullCheck(InstructorName.Text) && FieldValidation.NullCheck(InstructorPhone.Text) && FieldValidation.NullCheck(CourseName.Text)) { if (FieldValidation.EmailCheck(InstructorEmail.Text)) { if (_currentCourse.StartDate < _currentCourse.EndDate) { await _connection.UpdateAsync(_currentCourse); await Navigation.PopModalAsync(); } else { await DisplayAlert("Warning", "Please make sure the start date is before the end date", "Ok"); } } else { await DisplayAlert("Warning", "Please make sure your email is valid before submitting", "Ok"); } } else { await DisplayAlert("Warning", "Please make sure no fields are blank before submitting", "Ok"); } }