using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Fitness_core_BE.Models
{
///
/// Tenant-scoped physical-access identity. A platform user can belong to several
/// gyms, but receives one independent access profile per gym.
///
public class AccessProfile
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long AccessProfileId { get; set; }
public Guid FKClientId { get; set; }
[ForeignKey(nameof(FKClientId))]
public Client Client { get; set; } = null!;
public Guid FKUserId { get; set; }
[ForeignKey(nameof(FKUserId))]
public User User { get; set; } = null!;
[MaxLength(20)]
public string PersonType { get; set; } = "Customer";
[MaxLength(128)]
public string DisplayName { get; set; } = string.Empty;
[MaxLength(20)]
public string DesiredAccessState { get; set; } = "Enabled";
public int DesiredVersion { get; set; } = 1;
[MaxLength(100)]
public string? LockReason { get; set; }
public DateTime? LockedAt { get; set; }
// ---- Face photo (Hikvision face library) ----
// The image itself is never persisted here: it travels in the UpsertFacePhoto
// DeviceCommand payload only until the terminal confirms enrolment, at which point
// the payload is purged. What survives is the enrolment state plus the device-side
// record id, which is what a later replace/delete needs.
/// True once the terminal has accepted a face for this profile.
public bool HasFacePhoto { get; set; }
/// "None" | "Pending" | "Synced" | "Failed".
[MaxLength(20)]
public string FacePhotoStatus { get; set; } = "None";
/// Hikvision face-record id (FPID) returned on enrolment.
[MaxLength(64)]
public string? FacePhotoFPID { get; set; }
/// Why the terminal rejected the face (not frontal, eyes closed, ...).
[MaxLength(500)]
public string? FacePhotoError { get; set; }
public DateTime? FacePhotoUpdatedAt { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
public ICollection DeviceBindings { get; set; } = new List();
}
}