/** * Allows user to remove an appointment. */ private void removeAppointment() //Accesible by the class and does not return a value. { string response = "";//Use input Appointment apptToRemove; Patient apptOwner; bool inMenu = true; bool invalidResponse = true; string apptPath = ""; try { while (inMenu) { DataPrinting.printPatients(practice); response = GeneralFunctions.getOptionalInput("Select Patient: ", false); //breaks loop to appointments menu if(response != "") //not equal to blank { if(DataSearching.patientExists(practice, response))//Checks patient exsists based on given ID { apptOwner = DataSearching.findPatient(practice, response); //sets patient as apptOwner with given ID invalidResponse = true; //Runs next while loop while (invalidResponse) { DataPrinting.printAppointments(apptOwner); //Shows appointment of apptOwner response = GeneralFunctions.getOptionalInput("Appointment: ", false); //Request appointment to delete or option to cancel if (response != "") { if (DataSearching.appointmentExists(apptOwner, response)) //Checks if appointment exsists based on given ID { apptToRemove = DataSearching.findAppointment(apptOwner, response); //Gets the appointment with that ID apptPath = $"{DataIO.patientPath}\\{apptOwner.getId()}\\Appointments\\{apptToRemove.getId()}"; //Determines the path to the appointments directory apptOwner.getAppointments().Remove(apptToRemove); //Gets the list of appointments and removes the given appointment. Directory.Delete(apptPath, true); //path to appointments, true = allowing you to deletes all the folders content. invalidResponse = false; } else { Console.WriteLine("Invalid appointment id."); } } else { invalidResponse = false; } } } else { Console.WriteLine("Patient does not exist."); } } else { inMenu = false; } } } catch (Exception e) { GeneralFunctions.errorHandler(e); } }