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>
55 lines
2.6 KiB
C#
55 lines
2.6 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Fitness_core_BE.Models
|
|
{
|
|
/// <summary>A physical area of the club (e.g. "Pool Area", "Indoor Gym", "Court 1") that can
|
|
/// both be booked (Booking/FacilitySession below) and fitted with its own fingerprint/face
|
|
/// terminal for membership-plan access scoping (AccessDevice.FKFacilityId,
|
|
/// CustomerPlanFacility). Merged from the formerly-separate Facility (bookable capacity) and
|
|
/// Place (access zone) concepts -- see the booking redesign plan for the migration that
|
|
/// carried Place's rows over reusing this table's original PlaceId values as FacilityId.</summary>
|
|
public class Facility
|
|
{
|
|
[Key]
|
|
public Guid FacilityId { get; set; }
|
|
|
|
public Guid FKClientId { get; set; }
|
|
[ForeignKey(nameof(FKClientId))]
|
|
public Client Client { get; set; }
|
|
|
|
[MaxLength(128)]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
/// <summary>Staff pre-creates fixed-time FacilitySessions (classes) that many bookings
|
|
/// share one capacity pool against. Independent of SupportsBooking -- both can be true,
|
|
/// e.g. a court that hosts a scheduled class AND accepts ad-hoc walk-in bookings outside
|
|
/// class hours.</summary>
|
|
public bool SupportsClasses { get; set; } = true;
|
|
|
|
/// <summary>A booking can claim one of NumberOfUnits identical units directly for an
|
|
/// arbitrary time window, no pre-created session needed (courts/pool). At least one of
|
|
/// SupportsClasses/SupportsBooking must be true.</summary>
|
|
public bool SupportsBooking { get; set; } = false;
|
|
|
|
[MaxLength(500)]
|
|
public string? Description { get; set; }
|
|
|
|
/// <summary>Default per-session headcount limit when SupportsClasses; a specific
|
|
/// FacilitySession can override.</summary>
|
|
public int DefaultCapacity { get; set; } = 1;
|
|
|
|
/// <summary>Number of identical, independently-bookable units when SupportsBooking (e.g.
|
|
/// 3 for "3 courts") -- availability is this minus overlapping non-cancelled/
|
|
/// non-completed WalkIn bookings in the requested window.</summary>
|
|
public int NumberOfUnits { get; set; } = 1;
|
|
|
|
/// <summary>Hourly rate used to compute a guest WalkIn booking's suggested AmountCharged
|
|
/// (PricePerHour * duration-in-hours) at creation time.</summary>
|
|
public decimal PricePerHour { get; set; } = 0m;
|
|
|
|
public bool IsActive { get; set; } = true;
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
}
|
|
}
|