Refactor CustomerPlanService to use FacilityRepository, remove PlaceService, and introduce RfidTagService

- Updated CustomerPlanService to replace references to PlaceRepo with FacilityRepository for managing customer plans and associated facilities.
- Removed PlaceService and its related methods, consolidating functionality into FacilityService.
- Added RfidTagService for managing RFID tags, including methods for creating, updating, and setting statuses of tags.
- Updated TenantDbContext to include new DbSet for RfidTags and CustomerPlanFacilities, and adjusted model configurations accordingly.
- Enhanced FacilityService to support new booking modes and validation for facility creation and updates.
This commit is contained in:
2026-09-29 13:02:52 +05:30
parent bffc9b1686
commit 7d8a8478ff
39 changed files with 1596 additions and 678 deletions
+26
View File
@@ -15,5 +15,31 @@ namespace Fitness_core_BE.Interfaces
Task<List<FacilitySession>> GetSessions(Guid clientId, Guid? facilityId, DateTime fromUtc, DateTime toUtc);
Task<int> GetActiveBookingCount(Guid facilitySessionId);
Task<FacilitySession?> CancelFacilitySession(Guid facilitySessionId, Guid clientId);
// Device binding (absorbed from the old IPlaceRepo -- one AccessDevice per Facility).
Task<AccessDevice?> GetDeviceByIdForClientAsync(Guid deviceId, Guid clientId);
Task<Dictionary<Guid, AccessDevice>> GetDevicesByFacilityIdsAsync(List<Guid> facilityIds);
Task<bool> IsDeviceAssignedToAnotherFacilityAsync(Guid deviceId, Guid facilityId);
Task AssignDeviceAsync(Guid facilityId, Guid deviceId);
Task UnassignDeviceAsync(Guid facilityId);
// CustomerPlan <-> Facility access-scoping (many-to-many). Replace-all semantics, like a
// tags field. Absorbed from the old IPlaceRepo.
Task SetPlanFacilitiesAsync(Guid customerPlanId, List<Guid> facilityIds);
Task<List<Guid>> GetFacilityIdsForPlanAsync(Guid customerPlanId);
Task<Dictionary<Guid, List<Guid>>> GetFacilityIdsByPlanIdsAsync(List<Guid> customerPlanIds);
Task<Dictionary<Guid, string>> GetFacilityNamesByIdsAsync(List<Guid> facilityIds);
// AdHoc booking support (new). See TenantDbContext's Booking (FKFacilityId, StartTime,
// EndTime) index comment -- overlap is checked here rather than by a DB constraint.
/// <summary>Counts non-cancelled/non-completed AdHoc bookings on this facility whose
/// [StartTime, EndTime) overlaps the given window. Pass excludeBookingId when
/// re-checking a booking being rescheduled, so it doesn't count against itself.</summary>
Task<int> GetOverlappingAdhocBookingCountAsync(Guid facilityId, DateTime startTime, DateTime endTime, Guid? excludeBookingId = null);
/// <summary>Issues a row lock on the facility (SELECT ... FOR UPDATE) inside the caller's
/// already-open unit-of-work transaction, serializing concurrent AdHoc-slot claims on the
/// same facility so two overlapping bookings can't both pass the overlap-count check.</summary>
Task LockFacilityForUpdateAsync(Guid facilityId);
}
}