Reputation: 1
Situation: I'm developing an app where you can book stations on a chosen date and time with durations of 1, 2 or 4 hours. UI of the app.
Question: What's the best way to prevent double bookings? They may also not overlap.
Important tables:
The code in 'items' of the gallery showing the stations:
SortByColumns(
Filter(
Stations;
Not(
Name in Filter(
Bookings;
(Begin >= VarBeginDateTime && End <= varEndDateTime && Name <> BookingStation.Name);
(Begin <= VarBeginDateTime && End <= varEndDateTime && Name <> BookingStation.Name);
(Begin >= VarBeginDateTime && Begin <= varEndDateTime && End >= varEndDateTime && Name <> BookingStation.Name);
(Begin <= VarBeginDateTime && End >= varEndDateTime && Name <> BookingStation.Name)
).Name
)
);
"cr8fc_number";
Ascending
)
OnSelect code from button Book:
Set(varNumDuration; varDuration);;
// Make booking
Patch(Bookings; Defaults(Bookings);
{Begin: VarBeginDateTime};
{End: varEndDateTime};
{BookingStation: varStationSelected};
{Duration: varDuration});;
// Send mail
Office365Outlook.SendEmailV2("[email protected]";"Confirmation booking "&varStationSelectedText;"
Dear "& varMyDetails.FullName & "," & "<br><br>These are your booking details:" &
"<br><br>Start: "&VarBeginDateTime & "<br> End: "&varEndDateTime& "<br> Duration: "&varDurationText& "<br> Station: "&varStationSelectedText
& "<br><br> Kind regards, <br> Booking station app");;
// Next screen
Navigate(ConfirmationScreen);;
Upvotes: 0
Views: 1217
Reputation: 547
This is not as much a PowerApps question as it is a logic question.
Say you have an appointment from 1 PM to 2 PM. You then need to check for a few things:
If this is the case, you have an open slot and know its safe to book.
Another way of doing it, for example, is to filter your bookings towards the day and do a CountRows to check if there is already a booking during the timeslot that is selected.
G'luck
Upvotes: 0