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:
@@ -4,20 +4,20 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
{
|
||||
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? FacilitySessionId { get; set; }
|
||||
public Guid FacilityId { get; set; }
|
||||
public string? FacilityName { get; set; }
|
||||
|
||||
/// <summary>"Scheduled" | "AdHoc" -- read off the facility, tells the FE which action set
|
||||
/// applies (e.g. AdHoc bookings can be rescheduled to any free time; Scheduled ones only
|
||||
/// to another session).</summary>
|
||||
/// <summary>"Scheduled" | "WalkIn" -- tells the FE which action set applies (e.g. WalkIn
|
||||
/// bookings can be rescheduled to any free time; Scheduled ones only to another
|
||||
/// session).</summary>
|
||||
public string BookingMode { get; set; } = string.Empty;
|
||||
|
||||
public DateTime StartTime { get; set; }
|
||||
public DateTime EndTime { get; set; }
|
||||
|
||||
/// <summary>Informational headcount, AdHoc only.</summary>
|
||||
/// <summary>Informational headcount, WalkIn only.</summary>
|
||||
public int? PartySize { get; set; }
|
||||
|
||||
public bool IsGuest { get; set; }
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
public Guid? CustomerId { get; set; }
|
||||
}
|
||||
|
||||
public class CreateAdhocBookingRequest
|
||||
public class CreateWalkInBookingRequest
|
||||
{
|
||||
[Required]
|
||||
public Guid FacilityId { get; set; }
|
||||
@@ -39,7 +39,7 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
public int? PartySize { get; set; }
|
||||
}
|
||||
|
||||
public class CreateGuestAdhocBookingRequest
|
||||
public class CreateGuestWalkInBookingRequest
|
||||
{
|
||||
[Required]
|
||||
public Guid FacilityId { get; set; }
|
||||
@@ -98,7 +98,7 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
public string OtpCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Picked from the club's managed RFID tag pool (GET api/client/rfid-tags?
|
||||
/// status=Available) -- never free-typed. Required in practice for an AdHoc booking's
|
||||
/// status=Available) -- never free-typed. Required in practice for a WalkIn booking's
|
||||
/// check-in; optional for Scheduled bookings that don't hand out a physical tag.</summary>
|
||||
public Guid? RfidTagId { get; set; }
|
||||
}
|
||||
@@ -115,14 +115,14 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
public string? GuestPhone { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Exactly one shape applies, matching the booking's current BookingMode: AdHoc
|
||||
/// <summary>Exactly one shape applies, matching the booking's current BookingMode: WalkIn
|
||||
/// bookings move within the SAME facility to a new StartTime/DurationMinutes; Scheduled
|
||||
/// bookings move to a different FacilitySession (also on the same facility). Only allowed
|
||||
/// while the booking is still Confirmed, and only onto a slot with room -- re-runs the same
|
||||
/// availability check as creation, excluding the booking's own current slot.</summary>
|
||||
public class RescheduleBookingRequest
|
||||
{
|
||||
// AdHoc reschedule.
|
||||
// WalkIn reschedule.
|
||||
public DateTime? StartTime { get; set; }
|
||||
[Range(1, int.MaxValue, ErrorMessage = "DurationMinutes must be at least 1")]
|
||||
public int? DurationMinutes { get; set; }
|
||||
|
||||
@@ -58,5 +58,14 @@ namespace Fitness_core_BE.DTOs.CustomerPlan
|
||||
/// <summary>Places this plan grants access to. Null/omitted or empty = unrestricted
|
||||
/// (reaches every active access device, today's behavior).</summary>
|
||||
public List<Guid>? PlaceIds { get; set; }
|
||||
|
||||
/// <summary>Set only by the Classes tab's "Manage Plan" action -- links this new plan to
|
||||
/// one class via CustomerPlanClass. Omitted for an ordinary gym plan.</summary>
|
||||
public Guid? FacilityClassId { get; set; }
|
||||
|
||||
/// <summary>Only meaningful when FacilityClassId is set -- whether this class plan also
|
||||
/// grants general gym-floor access ("class + gym" as one product) instead of class-only.
|
||||
/// Defaults to false (class-only) when omitted.</summary>
|
||||
public bool? GrantsGymAccess { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace Fitness_core_BE.DTOs.Facility
|
||||
{
|
||||
public class FacilityClassDto
|
||||
{
|
||||
public Guid FacilityClassId { get; set; }
|
||||
public Guid FacilityId { get; set; }
|
||||
public string? FacilityName { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
/// <summary>"Daily" | "Weekly" | "Monthly" | "Custom".</summary>
|
||||
public string RecurrenceType { get; set; } = string.Empty;
|
||||
/// <summary>"HH:mm" local time -- null for Custom.</summary>
|
||||
public string? StartTimeOfDay { get; set; }
|
||||
public int DurationMinutes { get; set; }
|
||||
public int WeekDaysMask { get; set; }
|
||||
public string? MonthDays { get; set; }
|
||||
public DateTime SeriesStartDate { get; set; }
|
||||
public DateTime? SeriesEndDate { get; set; }
|
||||
public int? Capacity { get; set; }
|
||||
public bool IsUnlimitedCapacity { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>A confirmed ad-hoc booking whose window overlaps an active class occurrence on
|
||||
/// the same facility -- surfaced so staff can resolve it via the existing Reschedule flow.</summary>
|
||||
public class SchedulingConflictDto
|
||||
{
|
||||
public Guid BookingId { get; set; }
|
||||
public Guid FacilityId { get; set; }
|
||||
public string? FacilityName { get; set; }
|
||||
public string? GuestName { get; set; }
|
||||
public DateTime StartTime { get; set; }
|
||||
public DateTime EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Fitness_core_BE.DTOs.Facility
|
||||
{
|
||||
public class CustomOccurrenceRequest
|
||||
{
|
||||
[Required]
|
||||
public DateTime StartTime { get; set; }
|
||||
|
||||
[Required, Range(1, int.MaxValue, ErrorMessage = "DurationMinutes must be at least 1")]
|
||||
public int DurationMinutes { get; set; }
|
||||
}
|
||||
|
||||
public class CreateFacilityClassRequest
|
||||
{
|
||||
[Required]
|
||||
public Guid FacilityId { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>"Daily" | "Weekly" | "Monthly" | "Custom".</summary>
|
||||
[Required]
|
||||
public string RecurrenceType { get; set; } = "Weekly";
|
||||
|
||||
/// <summary>"HH:mm" local time -- required unless RecurrenceType == "Custom".</summary>
|
||||
public string? StartTimeOfDay { get; set; }
|
||||
|
||||
[Range(1, int.MaxValue, ErrorMessage = "DurationMinutes must be at least 1")]
|
||||
public int DurationMinutes { get; set; } = 60;
|
||||
|
||||
/// <summary>Weekly only. Bit flags, Sunday = 1 through Saturday = 64.</summary>
|
||||
public int WeekDaysMask { get; set; }
|
||||
|
||||
/// <summary>Monthly only. Comma-separated day-of-month list, e.g. "1,15".</summary>
|
||||
public string? MonthDays { get; set; }
|
||||
|
||||
public DateTime? SeriesStartDate { get; set; }
|
||||
public DateTime? SeriesEndDate { get; set; }
|
||||
|
||||
public int? Capacity { get; set; }
|
||||
public bool IsUnlimitedCapacity { get; set; }
|
||||
|
||||
/// <summary>RecurrenceType == "Custom" only -- explicit occurrence windows.</summary>
|
||||
public List<CustomOccurrenceRequest>? CustomOccurrences { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateFacilityClassRequest
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? RecurrenceType { get; set; }
|
||||
public string? StartTimeOfDay { get; set; }
|
||||
public int? DurationMinutes { get; set; }
|
||||
public int? WeekDaysMask { get; set; }
|
||||
public string? MonthDays { get; set; }
|
||||
public DateTime? SeriesStartDate { get; set; }
|
||||
public DateTime? SeriesEndDate { get; set; }
|
||||
public int? Capacity { get; set; }
|
||||
public bool? IsUnlimitedCapacity { get; set; }
|
||||
public bool? IsActive { get; set; }
|
||||
|
||||
/// <summary>RecurrenceType == "Custom" only -- adds more explicit occurrences without
|
||||
/// touching existing ones (Custom has no rule to regenerate from).</summary>
|
||||
public List<CustomOccurrenceRequest>? AddCustomOccurrences { get; set; }
|
||||
}
|
||||
|
||||
public class MarkNotHeldRequest
|
||||
{
|
||||
public string? Reason { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
public Guid FacilityId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>"Scheduled" | "AdHoc".</summary>
|
||||
public string BookingMode { get; set; } = "Scheduled";
|
||||
public bool SupportsClasses { get; set; }
|
||||
public bool SupportsBooking { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public int DefaultCapacity { get; set; }
|
||||
public int NumberOfUnits { get; set; }
|
||||
@@ -27,20 +27,35 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
public DateTime StartTime { get; set; }
|
||||
public DateTime EndTime { get; set; }
|
||||
public int Capacity { get; set; }
|
||||
/// <summary>When true, Capacity above is meaningless -- this occurrence has no cap.</summary>
|
||||
public bool IsUnlimitedCapacity { get; set; }
|
||||
public int BookedCount { get; set; }
|
||||
public bool IsCancelled { get; set; }
|
||||
/// <summary>Null for a manually-created session; set for a class occurrence.</summary>
|
||||
public Guid? FacilityClassId { get; set; }
|
||||
public string? FacilityClassName { get; set; }
|
||||
public string? NotHeldReason { get; set; }
|
||||
public DateTime? NotHeldAt { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>GET api/client/facilities/availability -- how much room is left for a requested
|
||||
/// window, uniformly across both booking modes (TotalUnits/UnitsFree mean NumberOfUnits/
|
||||
/// overlap-count for AdHoc, DefaultCapacity/free-session-spots for Scheduled).</summary>
|
||||
/// window. A facility can support both booking and classes at once, so the two number pairs
|
||||
/// are independently nullable: null means "this facility doesn't offer that mode," not zero.
|
||||
/// BookingUnitsFree is forced to 0 when an active (non-cancelled) class occupies the window --
|
||||
/// a running class occupies the whole facility, not just a seat.</summary>
|
||||
public class FacilityAvailabilityDto
|
||||
{
|
||||
public Guid FacilityId { get; set; }
|
||||
public string FacilityName { get; set; } = string.Empty;
|
||||
public string BookingMode { get; set; } = string.Empty;
|
||||
public int TotalUnits { get; set; }
|
||||
public int UnitsFree { get; set; }
|
||||
public bool SupportsClasses { get; set; }
|
||||
public bool SupportsBooking { get; set; }
|
||||
public int? BookingTotalUnits { get; set; }
|
||||
public int? BookingUnitsFree { get; set; }
|
||||
public int? ClassTotalCapacity { get; set; }
|
||||
public int? ClassUnitsFree { get; set; }
|
||||
/// <summary>True when an overlapping class occurrence has no headcount cap -- when set,
|
||||
/// ClassTotalCapacity/ClassUnitsFree stay null (unbounded, not zero).</summary>
|
||||
public bool ClassIsUnlimitedCapacity { get; set; }
|
||||
public decimal PricePerHour { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>"Scheduled" | "AdHoc".</summary>
|
||||
[Required]
|
||||
public string BookingMode { get; set; } = "Scheduled";
|
||||
/// <summary>At least one of SupportsClasses/SupportsBooking must be true.</summary>
|
||||
public bool SupportsClasses { get; set; } = true;
|
||||
public bool SupportsBooking { get; set; } = false;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>Required (meaningfully) when BookingMode == "Scheduled".</summary>
|
||||
/// <summary>Required (meaningfully) when SupportsClasses.</summary>
|
||||
[Range(1, int.MaxValue, ErrorMessage = "DefaultCapacity must be at least 1")]
|
||||
public int DefaultCapacity { get; set; } = 1;
|
||||
|
||||
/// <summary>Required (meaningfully) when BookingMode == "AdHoc" -- e.g. 3 for "3 courts".</summary>
|
||||
/// <summary>Required (meaningfully) when SupportsBooking -- e.g. 3 for "3 courts".</summary>
|
||||
[Range(1, int.MaxValue, ErrorMessage = "NumberOfUnits must be at least 1")]
|
||||
public int NumberOfUnits { get; set; } = 1;
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
[Required]
|
||||
public Guid FacilityId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? BookingMode { get; set; }
|
||||
public bool? SupportsClasses { get; set; }
|
||||
public bool? SupportsBooking { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public int? DefaultCapacity { get; set; }
|
||||
public int? NumberOfUnits { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user