View and delete appointments
This commit is contained in:
@@ -421,7 +421,7 @@ namespace C969Project.Data
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Appointment> RetrieveAllAppointments()
|
||||
public static List<Appointment> RetrieveAllAppointments(int? userId = null)
|
||||
{
|
||||
using MySqlConnection connection = new MySqlConnection(AppSettings.GetSetting("ConnectionStrings", "DefaultConnection"));
|
||||
try
|
||||
@@ -436,7 +436,11 @@ namespace C969Project.Data
|
||||
|
||||
List<Appointment> appointments = new List<Appointment>();
|
||||
|
||||
using MySqlCommand command = new MySqlCommand("SELECT * FROM client_schedule.appointment", connection);
|
||||
string query = "SELECT * FROM client_schedule.appointment";
|
||||
if (userId.HasValue) query += " WHERE userId = @userId";
|
||||
using MySqlCommand command = new MySqlCommand(query, connection);
|
||||
if (userId.HasValue) command.Parameters.AddWithValue("@userId", userId.Value);
|
||||
|
||||
using MySqlDataReader reader = command.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user