- Edited
Hi all,
I am working on a problem and have a bit difficulty about the best approach and hoping someone has some good ideas and/or have done something similar in the past. First of all, I am more interested in thoughts on "high-level" approach i.e what to do (e.g take Reservation and then get Unit and do some check etc. etc.), not the actual implementation (actual rules, processes etc.).
I have BO Reservation and BO Unit (I have multiple Units) and BO UnitStatus (1 instance per date and connected to each unit i.e each Unit has UnitStatus for all dates e.g entire 2025 etc.. UnitStatus holds the date and availability status e.g Available/Not Available) what I need to check is if there are any doublebookings i.e bookings for same unit during the same dates and the solution has to be able to handle reservations checking in/checking out on the same date i.e one reservation can check out on a date and another reservation can check in on that same date as that don´t overlap but the solution should find all other cases e.g if one reservation has check in on a date and another reservation is either staying there or checking in at the same date etc. etc, you get the idea.
I have tried to do Reservation first i.e have a process get all reservations for a period and then loop through them one by one and looking at units booked for that reservation and then looking for other reservations with the same unit during the same dates. This got messy quick and I abandoned this approach. I then did Unit first i.e take have a process to get all units and then loop though them one by one and trying to find all reservations that has this unit for these dates etc. etc.. This also got messy and I didn´t get to a good solution.
Any ideas, what is the best approach?