using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Fitness_core_BE.Models
{
/// 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.
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; }
/// Overrides Facility.DefaultCapacity when set; null = use the facility default.
/// Ignored when IsUnlimitedCapacity is true.
public int? Capacity { get; set; }
/// 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.
public bool IsUnlimitedCapacity { get; set; } = false;
public bool IsCancelled { get; set; } = false;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
/// Null for a manually-created session (the pre-Classes path, unaffected).
/// Set for a class occurrence -- which FacilityClass generated or explicitly added it.
public Guid? FKFacilityClassId { get; set; }
[ForeignKey(nameof(FKFacilityClassId))]
public FacilityClass? FacilityClass { get; set; }
/// 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.
public string? NotHeldReason { get; set; }
public DateTime? NotHeldAt { get; set; }
public virtual ICollection Bookings { get; set; }
}
}