Refactor CustomerPlanService to use FacilityRepository, remove PlaceService, and introduce RfidTagService
- Updated CustomerPlanService to replace references to PlaceRepo with FacilityRepository for managing customer plans and associated facilities. - Removed PlaceService and its related methods, consolidating functionality into FacilityService. - Added RfidTagService for managing RFID tags, including methods for creating, updating, and setting statuses of tags. - Updated TenantDbContext to include new DbSet for RfidTags and CustomerPlanFacilities, and adjusted model configurations accordingly. - Enhanced FacilityService to support new booking modes and validation for facility creation and updates.
This commit is contained in:
@@ -3,10 +3,22 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
public class BookingDto
|
||||
{
|
||||
public Guid BookingId { get; set; }
|
||||
public Guid FacilitySessionId { get; set; }
|
||||
|
||||
/// <summary>Null for an AdHoc booking (no pre-created session).</summary>
|
||||
public Guid? FacilitySessionId { get; set; }
|
||||
public Guid FacilityId { get; set; }
|
||||
public string? FacilityName { get; set; }
|
||||
public DateTime? SessionStartTime { get; set; }
|
||||
public DateTime? SessionEndTime { get; set; }
|
||||
|
||||
/// <summary>"Scheduled" | "AdHoc" -- read off the facility, tells the FE which action set
|
||||
/// applies (e.g. AdHoc bookings can be rescheduled to any free time; Scheduled ones only
|
||||
/// to another session).</summary>
|
||||
public string BookingMode { get; set; } = string.Empty;
|
||||
|
||||
public DateTime StartTime { get; set; }
|
||||
public DateTime EndTime { get; set; }
|
||||
|
||||
/// <summary>Informational headcount, AdHoc only.</summary>
|
||||
public int? PartySize { get; set; }
|
||||
|
||||
public bool IsGuest { get; set; }
|
||||
public Guid? CustomerId { get; set; }
|
||||
@@ -18,11 +30,17 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
public string? OtpCode { get; set; }
|
||||
public bool OtpVerified { get; set; }
|
||||
|
||||
public Guid? RfidTagId { get; set; }
|
||||
public string? RfidTagLabel { get; set; }
|
||||
public DateTime? RfidAssignedAt { get; set; }
|
||||
public DateTime? RfidReturnedAt { get; set; }
|
||||
|
||||
public string PaymentStatus { get; set; } = string.Empty;
|
||||
public decimal AmountCharged { get; set; }
|
||||
public string Status { get; set; } = string.Empty;
|
||||
public DateTime BookedAt { get; set; }
|
||||
public DateTime? CheckedInAt { get; set; }
|
||||
public DateTime? CheckedOutAt { get; set; }
|
||||
|
||||
/// <summary>A public, unauthenticated link to this booking's confirmation page --
|
||||
/// copy-paste-and-share receipt. Works for both member and guest bookings.</summary>
|
||||
|
||||
@@ -20,6 +20,40 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
public string GuestPhone { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class CreateAdhocBookingRequest
|
||||
{
|
||||
[Required]
|
||||
public Guid FacilityId { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime StartTime { get; set; }
|
||||
|
||||
[Required, Range(1, int.MaxValue, ErrorMessage = "DurationMinutes must be at least 1")]
|
||||
public int DurationMinutes { get; set; }
|
||||
|
||||
public int? PartySize { get; set; }
|
||||
}
|
||||
|
||||
public class CreateGuestAdhocBookingRequest
|
||||
{
|
||||
[Required]
|
||||
public Guid FacilityId { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime StartTime { get; set; }
|
||||
|
||||
[Required, Range(1, int.MaxValue, ErrorMessage = "DurationMinutes must be at least 1")]
|
||||
public int DurationMinutes { get; set; }
|
||||
|
||||
[Required]
|
||||
public string GuestName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string GuestPhone { get; set; } = string.Empty;
|
||||
|
||||
public int? PartySize { get; set; }
|
||||
}
|
||||
|
||||
public class MarkGuestBookingPaidRequest
|
||||
{
|
||||
[Required]
|
||||
@@ -34,6 +68,11 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
{
|
||||
[Required]
|
||||
public string OtpCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Picked from the club's managed RFID tag pool (GET api/client/rfid-tags?
|
||||
/// status=Available) -- never free-typed. Required in practice for an AdHoc booking's
|
||||
/// check-in; optional for Scheduled bookings that don't hand out a physical tag.</summary>
|
||||
public Guid? RfidTagId { get; set; }
|
||||
}
|
||||
|
||||
public class CancelBookingRequest
|
||||
@@ -41,4 +80,26 @@ namespace Fitness_core_BE.DTOs.Booking
|
||||
[Required]
|
||||
public Guid BookingId { get; set; }
|
||||
}
|
||||
|
||||
public class ReassignBookingRequest
|
||||
{
|
||||
public string? GuestName { get; set; }
|
||||
public string? GuestPhone { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Exactly one shape applies, matching the booking's current BookingMode: AdHoc
|
||||
/// bookings move within the SAME facility to a new StartTime/DurationMinutes; Scheduled
|
||||
/// bookings move to a different FacilitySession (also on the same facility). Only allowed
|
||||
/// while the booking is still Confirmed, and only onto a slot with room -- re-runs the same
|
||||
/// availability check as creation, excluding the booking's own current slot.</summary>
|
||||
public class RescheduleBookingRequest
|
||||
{
|
||||
// AdHoc reschedule.
|
||||
public DateTime? StartTime { get; set; }
|
||||
[Range(1, int.MaxValue, ErrorMessage = "DurationMinutes must be at least 1")]
|
||||
public int? DurationMinutes { get; set; }
|
||||
|
||||
// Scheduled reschedule.
|
||||
public Guid? FacilitySessionId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,19 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
{
|
||||
public Guid FacilityId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string FacilityType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>"Scheduled" | "AdHoc".</summary>
|
||||
public string BookingMode { get; set; } = "Scheduled";
|
||||
public string? Description { get; set; }
|
||||
public int DefaultCapacity { get; set; }
|
||||
public int NumberOfUnits { get; set; }
|
||||
public decimal PricePerHour { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
// Absorbed from the old PlaceDto -- at most one for now, see AccessDevice.FKFacilityId.
|
||||
public Guid? DeviceId { get; set; }
|
||||
public string? DeviceName { get; set; }
|
||||
}
|
||||
|
||||
public class FacilitySessionDto
|
||||
@@ -22,4 +30,17 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
public int BookedCount { get; set; }
|
||||
public bool IsCancelled { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>GET api/client/facilities/availability -- how much room is left for a requested
|
||||
/// window, uniformly across both booking modes (TotalUnits/UnitsFree mean NumberOfUnits/
|
||||
/// overlap-count for AdHoc, DefaultCapacity/free-session-spots for Scheduled).</summary>
|
||||
public class FacilityAvailabilityDto
|
||||
{
|
||||
public Guid FacilityId { get; set; }
|
||||
public string FacilityName { get; set; } = string.Empty;
|
||||
public string BookingMode { get; set; } = string.Empty;
|
||||
public int TotalUnits { get; set; }
|
||||
public int UnitsFree { get; set; }
|
||||
public decimal PricePerHour { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,22 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>"Gym" | "Pool" | "Court" | "Class".</summary>
|
||||
/// <summary>"Scheduled" | "AdHoc".</summary>
|
||||
[Required]
|
||||
public string FacilityType { get; set; } = "Class";
|
||||
public string BookingMode { get; set; } = "Scheduled";
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>Required (meaningfully) when BookingMode == "Scheduled".</summary>
|
||||
[Range(1, int.MaxValue, ErrorMessage = "DefaultCapacity must be at least 1")]
|
||||
public int DefaultCapacity { get; set; } = 1;
|
||||
|
||||
/// <summary>Required (meaningfully) when BookingMode == "AdHoc" -- e.g. 3 for "3 courts".</summary>
|
||||
[Range(1, int.MaxValue, ErrorMessage = "NumberOfUnits must be at least 1")]
|
||||
public int NumberOfUnits { get; set; } = 1;
|
||||
|
||||
[Range(typeof(decimal), "0", "79228162514264337593543950335", ErrorMessage = "PricePerHour cannot be negative")]
|
||||
public decimal PricePerHour { get; set; } = 0m;
|
||||
}
|
||||
|
||||
public class UpdateFacilityRequest
|
||||
@@ -22,9 +30,11 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
[Required]
|
||||
public Guid FacilityId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? FacilityType { get; set; }
|
||||
public string? BookingMode { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public int? DefaultCapacity { get; set; }
|
||||
public int? NumberOfUnits { get; set; }
|
||||
public decimal? PricePerHour { get; set; }
|
||||
public bool? IsActive { get; set; }
|
||||
}
|
||||
|
||||
@@ -48,4 +58,22 @@ namespace Fitness_core_BE.DTOs.Facility
|
||||
/// <summary>Overrides the facility's default capacity for this specific session.</summary>
|
||||
public int? Capacity { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>Absorbed from the old AssignPlaceDeviceRequest.</summary>
|
||||
public class AssignFacilityDeviceRequest
|
||||
{
|
||||
// Null unassigns the facility's current device.
|
||||
public Guid? DeviceId { get; set; }
|
||||
}
|
||||
|
||||
public class GetFacilityAvailabilityRequest
|
||||
{
|
||||
public Guid? FacilityId { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime StartTime { get; set; }
|
||||
|
||||
[Required, Range(1, int.MaxValue, ErrorMessage = "DurationMinutes must be at least 1")]
|
||||
public int DurationMinutes { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace Fitness_core_BE.DTOs.Place
|
||||
{
|
||||
public class PlaceDto
|
||||
{
|
||||
public Guid PlaceId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
// At most one for now -- see AccessDevice.FKPlaceId.
|
||||
public Guid? DeviceId { get; set; }
|
||||
public string? DeviceName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Fitness_core_BE.DTOs.Place
|
||||
{
|
||||
public class CreatePlaceRequest
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
||||
public class UpdatePlaceRequest
|
||||
{
|
||||
[Required]
|
||||
public Guid PlaceId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public bool? IsActive { get; set; }
|
||||
}
|
||||
|
||||
public class SetPlaceStatusRequest
|
||||
{
|
||||
[Required]
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
|
||||
public class AssignPlaceDeviceRequest
|
||||
{
|
||||
// Null unassigns the place's current device.
|
||||
public Guid? DeviceId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Fitness_core_BE.DTOs.RfidTag
|
||||
{
|
||||
public class RfidTagDto
|
||||
{
|
||||
public Guid RfidTagId { get; set; }
|
||||
public string TagCode { get; set; } = string.Empty;
|
||||
public string? Label { get; set; }
|
||||
|
||||
/// <summary>"Available" | "InUse" | "Lost" | "Retired".</summary>
|
||||
public string Status { get; set; } = string.Empty;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Fitness_core_BE.DTOs.RfidTag
|
||||
{
|
||||
public class CreateRfidTagRequest
|
||||
{
|
||||
[Required]
|
||||
public string TagCode { get; set; } = string.Empty;
|
||||
public string? Label { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateRfidTagRequest
|
||||
{
|
||||
public string? TagCode { get; set; }
|
||||
public string? Label { get; set; }
|
||||
}
|
||||
|
||||
public class SetRfidTagStatusRequest
|
||||
{
|
||||
/// <summary>"Available" | "Lost" | "Retired" only -- "InUse" is never staff-settable
|
||||
/// directly, only reached via a booking check-in.</summary>
|
||||
[Required]
|
||||
public string Status { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user