private void Confirm_Click(object sender, RoutedEventArgs e) { Patient patient = (Patient)PatientComboBox.SelectedItem; Doctor doctor = (Doctor)DoctorComboBox.SelectedItem; Room room = (Room)RoomComboBox.SelectedItem; if (ConfirmCheck()) { ComboBoxItem item = time.SelectedItem as ComboBoxItem; DateTime dateTime = DateTime.Parse(date.Text + " " + item.Content.ToString()); AppointmentType type = (AppointmentType)TypeComboBox.SelectedIndex; Appointment appointment = new Appointment(_appointmentController.GenerateNewId(), dateTime, 15, type, AppointmentStatus.scheduled, patient, doctor, room); _appointmentController.Add(appointment); parent.Main.Content = new AppointmentsPage(parent); this.Close(); } }