canBook method
bool
canBook({
- required List<
IsibookCalendarSlot> slots, - required int startIndex,
- required int length,
Verifica se è possibile prenotare una sequenza di slot a partire da startIndex
lunga length slot, rispettando min/max_number_slot_reserved e disponibilità.
Implementation
bool canBook({
required List<IsibookCalendarSlot> slots,
required int startIndex,
required int length,
}) {
// Rispetta i vincoli min/max dello space
if (length < minNumberSlotReserved || length > maxNumberSlotReserved) {
return false;
}
// Limiti della lista
if (startIndex < 0 || startIndex + length > slots.length) {
return false;
}
// Tutti gli slot della finestra devono essere disponibili
for (int i = startIndex; i < startIndex + length; i++) {
if (!slots[i].available) {
return false;
}
}
return true;
}