using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Fitness_core_BE.Models { /// 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. 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; } /// "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. [MaxLength(20)] public string RecurrenceType { get; set; } = "Weekly"; /// 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. public TimeSpan StartTimeOfDay { get; set; } public int DurationMinutes { get; set; } = 60; /// Weekly only. Bit flags, Sunday = 1 (bit 0) through Saturday = 64 (bit 6). public int WeekDaysMask { get; set; } = 0; /// Monthly only. Comma-separated day-of-month list, e.g. "1,15". [MaxLength(200)] public string? MonthDays { get; set; } /// Unused for Custom (occurrences are explicit, not generated from a range). public DateTime SeriesStartDate { get; set; } = DateTime.UtcNow.Date; /// Null = ongoing, no end date. Unused for Custom. public DateTime? SeriesEndDate { get; set; } /// Null = unlimited (see IsUnlimitedCapacity); otherwise the per-occurrence /// headcount cap, same meaning as Facility.DefaultCapacity/FacilitySession.Capacity. public int? Capacity { get; set; } /// 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. public bool IsUnlimitedCapacity { get; set; } = false; public bool IsActive { get; set; } = true; /// 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). public DateTime OccurrencesGeneratedThrough { get; set; } = DateTime.UtcNow.Date; public DateTime CreatedAt { get; set; } = DateTime.UtcNow; } }