Facility booking-mode redesign, multi-plan subscriptions, and Classes

Implements the facility-classes-booking-dashboard plan (backend):

- Facility.BookingMode (single Scheduled/AdHoc choice) replaced with
  independent SupportsClasses/SupportsBooking flags, so one facility
  can run a class and accept walk-in bookings; a running class now
  blocks walk-in booking for its window on both create and reschedule.
- CustomerPlan.GrantsGymAccess + CustomerPlanClass join table let a
  customer hold one gym-access plan plus any number of class-only
  plans. Replaced the old single-subscription resolution
  (GetActiveSubscriptionByCustomerId/HasAnyActiveSubscriptionAsync)
  with gym-access-aware and class-aware resolvers across booking
  creation/cancellation, plan assignment, and customer self-service.
  Fixed ChangeMembershipPlan/renewal plan-changes, which resolved "the
  subscription to replace" by most-recent-created and would have
  deactivated a member's class subscription instead of their gym one.
- New FacilityClass model: recurring class definitions (Daily/Weekly/
  Monthly/Custom) with lazy occurrence generation (8-week horizon,
  race-safe via a unique index) and proper unlimited-capacity handling.
  "Mark not held" replaces the old bare-cancel: cascades to cancel and
  refund every confirmed booking on the occurrence through the same
  core CancelBooking uses, and frees the slot for walk-in booking.
  Scheduling conflicts (a walk-in booking now overlapping a class) are
  surfaced for staff to resolve via the existing Reschedule flow.
- Renamed the pre-existing "AdHoc" booking-mode terminology to
  "WalkIn" throughout (routes, methods, DTOs, the stored BookingMode
  value) for a clearer, simpler name.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 14:26:59 +05:30
parent 1a502767ba
commit 5d711bd13e
38 changed files with 1437 additions and 226 deletions
+7 -7
View File
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Fitness_core_BE.Models
{
/// <summary>One reservation against a Facility — either a Scheduled-mode booking against a
/// pre-created FacilitySession (many bookings share one capacity pool), or an AdHoc-mode
/// pre-created FacilitySession (many bookings share one capacity pool), or a WalkIn-mode
/// booking that claims one of the Facility's NumberOfUnits directly for an arbitrary time
/// window, no session needed. Either an existing member using a CustomerPlan session
/// allowance (FKCustomerId set, IsGuest = false) or a non-member who booked online and pays
@@ -16,28 +16,28 @@ namespace Fitness_core_BE.Models
[Key]
public Guid BookingId { get; set; }
/// <summary>Null for an AdHoc booking (no pre-created session).</summary>
/// <summary>Null for a WalkIn booking (no pre-created session).</summary>
public Guid? FKFacilitySessionId { get; set; }
[ForeignKey(nameof(FKFacilitySessionId))]
public FacilitySession? FacilitySession { get; set; }
/// <summary>Always set, for both modes -- copied from FacilitySession.FKFacilityId at
/// creation (Scheduled) or the booked facility directly (AdHoc). Every place that needs
/// creation (Scheduled) or the booked facility directly (WalkIn). Every place that needs
/// "which facility / what time window" reads these (and StartTime/EndTime below)
/// uniformly instead of reaching through FacilitySession, which doesn't exist for AdHoc
/// uniformly instead of reaching through FacilitySession, which doesn't exist for WalkIn
/// bookings.</summary>
public Guid FKFacilityId { get; set; }
[ForeignKey(nameof(FKFacilityId))]
public Facility Facility { get; set; }
/// <summary>Copied from FacilitySession.StartTime (Scheduled) or the requested start
/// (AdHoc) at creation; updated in place by Reschedule.</summary>
/// (WalkIn) at creation; updated in place by Reschedule.</summary>
public DateTime StartTime { get; set; }
/// <summary>Same pattern as StartTime.</summary>
public DateTime EndTime { get; set; }
/// <summary>Informational headcount for an AdHoc booking (e.g. "how many will come") --
/// never enforced as a capacity mechanic; each AdHoc booking claims one whole unit
/// <summary>Informational headcount for a WalkIn booking (e.g. "how many will come") --
/// never enforced as a capacity mechanic; each WalkIn booking claims one whole unit
/// regardless of party size. Null for Scheduled bookings.</summary>
public int? PartySize { get; set; }