using GB5Shared.DTO.Framework.Login; using IceImportDAL.CustomCode.GcmCodeLookup; namespace IceImportBLL.LookupProvider; // The one concrete ILookupProvider implementation for Phase 1, wrapping IGcmCodeLookupDAL. // // Design note: GCM-scoped lookups are disambiguated by GcmTypeId (IceMapDetailsDTO.GcmTypeId, // set per row by the IceMap admin config), not by a single fixed MENTITY EntityId — there is no // schema mapping tying one EntityId to exactly one GcmTypeId. EntityId=-1 is a sentinel meaning // "never matched by EntityLookupService's ordinary EntityId-keyed ILookupProvider scan"; instead // EntityLookupService detects GcmTypeId > 0 directly on the IceMapDetails row and calls // ResolveByGcmTypeAsync (below) explicitly, grouped by GcmTypeId. This class still fully // implements ILookupProvider so it participates in the DI-scanned plugin pattern and remains // independently unit-testable/injectable like any other provider. public class GcmCodeLookupProvider : ILookupProvider { public int EntityId => -1; private readonly IGcmCodeLookupDAL _dal; public GcmCodeLookupProvider(IGcmCodeLookupDAL dal) => _dal = dal; public Task> ResolveCodesToIdsAsync( IEnumerable codes, LoginDTO login, CancellationToken ct) => throw new NotSupportedException( "GcmCodeLookupProvider requires a GcmTypeId — call ResolveByGcmTypeAsync directly " + "instead of the generic EntityId-keyed ILookupProvider dispatch."); public Task> ResolveNamesToIdsAsync( IEnumerable names, LoginDTO login, CancellationToken ct) => throw new NotSupportedException( "GcmCodeLookupProvider requires a GcmTypeId — call ResolveByGcmTypeAsync directly " + "instead of the generic EntityId-keyed ILookupProvider dispatch."); public Task> ResolveByGcmTypeAsync( int gcmTypeId, IEnumerable values, bool byName, LoginDTO login, CancellationToken ct) => byName ? _dal.ResolveNamesToIdsAsync(gcmTypeId, values, login, ct) : _dal.ResolveCodesToIdsAsync(gcmTypeId, values, login, ct); }