Files
Core_Be/Models/AccessDevice.cs
T
HarithaRandunu 7d8a8478ff 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.
2026-09-29 13:02:52 +05:30

66 lines
3.1 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Security.Cryptography;
using System.Text;
namespace Fitness_core_BE.Models
{
public class AccessDevice
{
[Key]
public Guid DeviceId { get; set; }
public string DeviceName { get; set; }
// DEPRECATED: connection details now live on the on-prem agent (Fitness_core_BE.Models.Agent),
// not in the cloud. Kept nullable so existing rows survive; no new code should read/write these.
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
public string? PublicIp { get; set; }
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
public string? Port { get; set; }
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
public string? UserName { get; set; }
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
public string? Password { get; set; }
public Guid FKClientId { get; set; }
[ForeignKey("FKClientId")]
public Client Client { get; set; }
// The agent that currently owns this LAN device. Commands are dispatched only
// to this agent, which prevents a second agent for the same gym receiving them.
public Guid? FKAgentId { get; set; }
[ForeignKey(nameof(FKAgentId))]
public Agent? Agent { get; set; }
// Stable serial/device identifier reported by ISAPI. Used to re-claim the same
// cloud row after reinstalling the desktop agent instead of creating duplicates.
[MaxLength(160)]
public string? HardwareId { get; set; }
// Which Facility (physical zone) this terminal sits in. Null = unscoped: reachable by
// every plan regardless of that plan's Facilities (keeps pre-existing devices and
// plans without any facility restriction working unchanged). Unique when set --
// exactly one device per facility for now (see Models/Facility.cs).
public Guid? FKFacilityId { get; set; }
[ForeignKey(nameof(FKFacilityId))]
public Facility? Facility { get; set; }
public bool IsActive { get; set; } = true;
public DateTime? LastSeenAt { get; set; }
// Explicit reachability reported by the on-prem agent. LastSeenAt remains
// the last successful terminal operation; health reports are tracked
// separately so status does not depend on browser polling.
public bool IsReachable { get; set; }
public DateTime? LastHealthReportedAt { get; set; }
public DateTime CreatedAt { get; set; }= DateTime.UtcNow;
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
public void SetPassword(string plainText)
=> Password = EncryptionHelper.Encrypt(plainText);
[Obsolete("Device connection details now live on the on-prem agent, not in the cloud.")]
public string GetPlainTextPassword()
=> EncryptionHelper.Decrypt(Password!);
}
}