Reservation System Overbooking ERROR

4
Hello,   I am working on a reservations app for a restaurant. While there is 1 table left, if 2 different people press the registration button at the same time or 2-3 second difference, both of them can able to register. The overbooking happen.    How can I solve this issue? Wjhat is the best practice?
asked
3 answers
1

There are two things you could do.

1) As soon as someone selects a table, change the tables reservation status, so it will not appear in the list of available tables for other people. For that you could use a reservation status enum with eg free, beginviewed, reserved.

2) separate, but also as fallback for 1. When someone confirms the reservation, you can call a microflow that first retrieves the desired table object from the DB and checks the status. If not reserved, you can continue and update the status of the table to reserved. The second person will not be able to reserve, because the check fails and you could add a pop up like, sorry someone else just reserved the table.

answered
1

I think this can be handled in the below logic implementation.

 

a. When the user selects a table for a reservation, that table status needs to be changed to Booking-In-Progress. 

b. Since this table is marked with Booking-In-Progress status, any subsequent Tables searches by other users will exclude this table (No one will be able to reserve this table).

c. You have to set a time limit (Say 1 Minute) to complete the reservation. If the time limit is expired, the table status will return back to 'Available'. This can be done by a scheduled job that selects all the tables with status Booking-In-Progress and setting it back to 'Available if the time limit is expired.

 

d. If the user completes the reservation, the status should change to Reservation-complete. This table wont be listed until the reservation window is over.

 

Hope this helps.

answered
-2

May be you can handle through Before Commit event.

 

Check from the database if the table is already booked by someone

If booked then revert the booking status for the current user and show a message to the user saying the table is already booked by someone.

answered