@@ -377,6 +377,25 @@ def get_all_waitlist_entries():
377
377
print (f"Error fetching waitlist entries: { err } " )
378
378
return None
379
379
380
+ def remove_reservation_by_id (reservation_id ):
381
+ connection = get_db_connection (db_config )
382
+ if connection :
383
+ try :
384
+ cursor = connection .cursor ()
385
+ query = """
386
+ DELETE FROM Reservations
387
+ WHERE ReservationID = %s
388
+ """
389
+ cursor .execute (query , (reservation_id ,))
390
+ connection .commit ()
391
+ cursor .close ()
392
+ connection .close ()
393
+ return {'message' : 'Reservation removed successfully' }
394
+ except mysql .connector .Error as err :
395
+ print (f"Error removing reservation: { err } " )
396
+ connection .rollback ()
397
+ return {'error' : f"Error removing reservation: { err } " }
398
+
380
399
def move_to_completed_reservations (reservation_id ):
381
400
connection = get_db_connection (db_config )
382
401
if connection :
@@ -402,10 +421,7 @@ def move_to_completed_reservations(reservation_id):
402
421
)
403
422
cursor .execute (insert_query , values )
404
423
405
- delete_query = """
406
- DELETE FROM Reservations WHERE ReservationID = %s
407
- """
408
- cursor .execute (delete_query , (reservation_id ,))
424
+ remove_reservation_by_id (reservation_id )
409
425
410
426
connection .commit ()
411
427
cursor .close ()
@@ -435,6 +451,7 @@ def check_reservation_end_route():
435
451
print (f"Fetched Reservations: { reservations } " ) # Debugging line
436
452
437
453
for reservation in reservations :
454
+ print (f"EndTime of Reservation { reservation ['ReservationID' ]} : { reservation ['EndTime' ]} " )
438
455
move_to_completed_reservations (reservation ['ReservationID' ])
439
456
440
457
cursor .close ()
@@ -445,6 +462,7 @@ def check_reservation_end_route():
445
462
print (f"Error checking reservations end: { e } " )
446
463
return jsonify (error = 'Error checking reservations end' ), 500
447
464
465
+
448
466
@app .route ('/api/remove-reservation/<string:chair_id>' , methods = ['DELETE' ])
449
467
def remove_reservation_route (chair_id ):
450
468
try :
0 commit comments