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:
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user