namespace Campaign_Tracker.Server.ExtensionData; /// /// Immutable value object that an extension record stores as its required legacy foreign reference. /// Carry the and the string representation of the join key so /// the anti-corruption layer can resolve it unambiguously (AC #2). /// public sealed record LegacyLinkReference(LegacyLinkType Type, string Value) { public static LegacyLinkReference ForJurisdiction(string jCode) { ArgumentException.ThrowIfNullOrWhiteSpace(jCode); return new(LegacyLinkType.JurisdictionJCode, jCode); } public static LegacyLinkReference ForKit(int id) => id <= 0 ? throw new ArgumentOutOfRangeException(nameof(id), "Kit ID must be greater than zero.") : new(LegacyLinkType.KitId, id.ToString(System.Globalization.CultureInfo.InvariantCulture)); public static LegacyLinkReference ForContact(int id) => id <= 0 ? throw new ArgumentOutOfRangeException(nameof(id), "Contact ID must be greater than zero.") : new(LegacyLinkType.ContactId, id.ToString(System.Globalization.CultureInfo.InvariantCulture)); public override string ToString() => $"{Type}:{Value}"; }