/// <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 TestFosterAppointmentManagerUpdateFosterAppointment() { FosterAppointment oldAppt = new FosterAppointment() { FosterAppointmentID = 27, VolunteerID = 1 }; FosterAppointment newAppt = new FosterAppointment() { FosterAppointmentID = 27, VolunteerID = 2 }; manager.ScheduleFosterAppointment(oldAppt); bool result = manager.UpdateFosterAppointment(oldAppt, newAppt); Assert.IsTrue(result); }