Files
Core_Be/Models/TenantCustomerLink.cs
T
Dhananjaya99 bffc9b1686 first commit
2026-09-28 11:44:26 +05:30

34 lines
1.7 KiB
C#

using System.ComponentModel.DataAnnotations;
namespace Fitness_core_BE.Models
{
// Tenant-DB only, one row per customer this gym has ever enrolled. Every tenant-local
// table that used to FK straight to the central Customer.CusId keeps doing so, unchanged
// -- TenantCustomerLinkId IS the central Customer.CusId (same GUID value), not a new
// surrogate key. That's deliberate: a fresh surrogate key would mean "customerId" holds
// a different value depending on whether it's about to query a central or a tenant table,
// which is exactly the kind of silent, hard-to-spot bug this split needs to avoid. EF/MySQL
// still can't enforce this as a real cross-schema FK constraint -- it's just data -- but the
// ID space stays uniform everywhere, and this row is also the local anchor tenant tables
// join against for cached display fields without a central round-trip.
public class TenantCustomerLink
{
[Key]
public Guid TenantCustomerLinkId { get; set; } // == central Customer.CusId
// = the shared login User id (same GUID in Auth's Users table), cached.
public Guid CentralUserId { get; set; }
public string? DisplayName { get; set; }
public string? PrimaryPhoneCached { get; set; }
public string? EmailCached { get; set; }
// What a client-initiated delete flips. Central Customer.IsActive is never touched
// by a client-initiated delete -- see CustomerRepository.DeactivateCustomerForClient.
public bool IsActiveAtThisClient { get; set; } = true;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}
}