5d711bd13e
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>
52 lines
2.3 KiB
C#
52 lines
2.3 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Fitness_core_BE.Models
|
|
{
|
|
/// <summary>One scheduled, bookable occurrence of a Facility (e.g. "Pool, Tue 6-7pm").
|
|
/// Capacity is enforced by counting non-cancelled Bookings against this row, not by a
|
|
/// denormalized counter, to avoid drift between the two.</summary>
|
|
public class FacilitySession
|
|
{
|
|
[Key]
|
|
public Guid FacilitySessionId { get; set; }
|
|
|
|
public Guid FKFacilityId { get; set; }
|
|
[ForeignKey(nameof(FKFacilityId))]
|
|
public Facility Facility { get; set; }
|
|
|
|
public Guid FKClientId { get; set; }
|
|
[ForeignKey(nameof(FKClientId))]
|
|
public Client Client { get; set; }
|
|
|
|
public DateTime StartTime { get; set; }
|
|
public DateTime EndTime { get; set; }
|
|
|
|
/// <summary>Overrides Facility.DefaultCapacity when set; null = use the facility default.
|
|
/// Ignored when IsUnlimitedCapacity is true.</summary>
|
|
public int? Capacity { get; set; }
|
|
|
|
/// <summary>Copied from FacilityClass.IsUnlimitedCapacity at generation time (or set
|
|
/// directly for a manually-created session) -- see that flag's doc comment for why this
|
|
/// isn't just a Capacity sentinel value.</summary>
|
|
public bool IsUnlimitedCapacity { get; set; } = false;
|
|
|
|
public bool IsCancelled { get; set; } = false;
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
/// <summary>Null for a manually-created session (the pre-Classes path, unaffected).
|
|
/// Set for a class occurrence -- which FacilityClass generated or explicitly added it.</summary>
|
|
public Guid? FKFacilityClassId { get; set; }
|
|
[ForeignKey(nameof(FKFacilityClassId))]
|
|
public FacilityClass? FacilityClass { get; set; }
|
|
|
|
/// <summary>Set together by FacilityService's "mark not held" cascade (which replaces
|
|
/// the old bare-IsCancelled CancelFacilitySession) -- null means this occurrence is
|
|
/// either still scheduled or was never a class occurrence at all.</summary>
|
|
public string? NotHeldReason { get; set; }
|
|
public DateTime? NotHeldAt { get; set; }
|
|
|
|
public virtual ICollection<Booking> Bookings { get; set; }
|
|
}
|
|
}
|