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>
72 lines
3.5 KiB
C#
72 lines
3.5 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Fitness_core_BE.Models
|
|
{
|
|
/// <summary>A recurring class definition (Zumba, Yoga) on a Facility that SupportsClasses --
|
|
/// generates FacilitySession rows ("occurrences") on a schedule. Replaces manually creating
|
|
/// one-off FacilitySession rows from the Bookings page for anything that recurs.</summary>
|
|
public class FacilityClass
|
|
{
|
|
[Key]
|
|
public Guid FacilityClassId { get; set; }
|
|
|
|
public Guid FKClientId { get; set; }
|
|
[ForeignKey(nameof(FKClientId))]
|
|
public Client Client { get; set; }
|
|
|
|
public Guid FKFacilityId { get; set; }
|
|
[ForeignKey(nameof(FKFacilityId))]
|
|
public Facility Facility { get; set; }
|
|
|
|
[MaxLength(128)]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
[MaxLength(500)]
|
|
public string? Description { get; set; }
|
|
|
|
/// <summary>"Daily" | "Weekly" | "Monthly" | "Custom". Custom skips every rule field
|
|
/// below -- occurrences are written explicitly (as FacilitySession rows) at creation/
|
|
/// edit time with their own dates, instead of being generated from a rule.</summary>
|
|
[MaxLength(20)]
|
|
public string RecurrenceType { get; set; } = "Weekly";
|
|
|
|
/// <summary>The class's daily time window, in the facility's local time (not UTC) -- the
|
|
/// generator converts to UTC per-occurrence using the club's timezone. Unused (0) for
|
|
/// Custom, where each occurrence's own FacilitySession.StartTime/EndTime is explicit.</summary>
|
|
public TimeSpan StartTimeOfDay { get; set; }
|
|
public int DurationMinutes { get; set; } = 60;
|
|
|
|
/// <summary>Weekly only. Bit flags, Sunday = 1 (bit 0) through Saturday = 64 (bit 6).</summary>
|
|
public int WeekDaysMask { get; set; } = 0;
|
|
|
|
/// <summary>Monthly only. Comma-separated day-of-month list, e.g. "1,15".</summary>
|
|
[MaxLength(200)]
|
|
public string? MonthDays { get; set; }
|
|
|
|
/// <summary>Unused for Custom (occurrences are explicit, not generated from a range).</summary>
|
|
public DateTime SeriesStartDate { get; set; } = DateTime.UtcNow.Date;
|
|
/// <summary>Null = ongoing, no end date. Unused for Custom.</summary>
|
|
public DateTime? SeriesEndDate { get; set; }
|
|
|
|
/// <summary>Null = unlimited (see IsUnlimitedCapacity); otherwise the per-occurrence
|
|
/// headcount cap, same meaning as Facility.DefaultCapacity/FacilitySession.Capacity.</summary>
|
|
public int? Capacity { get; set; }
|
|
|
|
/// <summary>When true, Capacity is ignored and every generated occurrence has no cap --
|
|
/// a distinct flag rather than a sentinel value, since FacilitySession.Capacity == null
|
|
/// already means "use the facility default," and int.MaxValue would overflow the
|
|
/// checked Sum() in FacilityService.GetAvailability.</summary>
|
|
public bool IsUnlimitedCapacity { get; set; } = false;
|
|
|
|
public bool IsActive { get; set; } = true;
|
|
|
|
/// <summary>Watermark: occurrences have been generated through this date already.
|
|
/// Advanced by FacilityService.EnsureOccurrencesGeneratedAsync; never consulted for
|
|
/// Custom classes (their occurrences are all written explicitly, never generated).</summary>
|
|
public DateTime OccurrencesGeneratedThrough { get; set; } = DateTime.UtcNow.Date;
|
|
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
}
|
|
}
|