/// <summary> /// Creator: Timothy Lickteig /// Created: 04/27/2020 /// Approver: Zoey McDonald /// /// Submit button event handler /// </summary> /// <remarks> /// Updater: N/A /// Updated: N/A /// Update: N/A /// </remarks> private void BtnSubmit_Click(object sender, RoutedEventArgs e) { //Basic input validation if (null == cboVolunteerList.SelectedItem) { MessageBox.Show("Please select a volunteer"); } else if (txtStartTime.Text == "") { MessageBox.Show("Please enter a valid start time"); } else if (txtEndTime.Text == "") { MessageBox.Show("Please enter a valid end time"); } else { try { //Try to format the start and end times DateTime startTime = DateTime.Parse(txtStartTime.Text); DateTime endTime = DateTime.Parse(txtEndTime.Text); //Get the volunteer ID int volunteerID = volManager.GetVolunteerByName( volunteers[cboVolunteerList.SelectedIndex].FirstName, volunteers[cboVolunteerList.SelectedIndex].LastName) [0].VolunteerID; //Create a new foster appointment FosterAppointment appointment = new FosterAppointment() { VolunteerID = volunteerID, StartTime = startTime, EndTime = endTime, Description = txtDescription.Text }; if (null == toEdit) { fosterManager.ScheduleFosterAppointment(appointment); MessageBox.Show("Foster appointment scheduled"); } else { fosterManager.UpdateFosterAppointment(toEdit, appointment); MessageBox.Show("Appointment updated"); } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void TestFosterAppointmentManagerScheduleAppointment() { bool success = false; FosterAppointment appointment = new FosterAppointment() { VolunteerID = 1000000, StartTime = new DateTime(1, 1, 1, 12, 0, 0), EndTime = new DateTime(1, 1, 1, 14, 0, 0), }; success = manager.ScheduleFosterAppointment(appointment); Assert.AreEqual(true, success); }