using GB5Shared.DTO.Framework.Login; using GB5Shared.ScanIdentifier; using MMDAL.CustomCode.ScanTarget; namespace MMBLL.ScanTarget; // MM's resolver for the Scan-Identifier & Label Platform (GB5Shared/ScanIdentifier) — "TINDENTDETAIL" // (WorkOrderDetail). Registered here rather than in WI: an Indent Detail is a real MM/Indent entity // — WI only ever referenced it for the scan use case, so generation ownership belongs with the // module that owns the table. WI's own VerifyScan/List/Print facilities keep working against it // unchanged, since MSCANIDENTIFIER is one shared table read directly regardless of which host // generated a given row. public class IndentDetailResolver : IScanTargetResolver { private readonly IIndentDetailScanTargetDAL _dal; public IndentDetailResolver(IIndentDetailScanTargetDAL dal) => _dal = dal; public IEnumerable SupportedEntityTypes => new[] { "TINDENTDETAIL" }; public async Task ExistsAsync(string entityId, LoginDTO login, CancellationToken ct) => int.TryParse(entityId, out var indentDetailId) && await _dal.GetByIdAsync(indentDetailId, login, ct).ConfigureAwait(false) is not null; public async Task GetDisplayAsync(string entityId, LoginDTO login, CancellationToken ct) { if (!int.TryParse(entityId, out var indentDetailId)) return null; var row = await _dal.GetByIdAsync(indentDetailId, login, ct).ConfigureAwait(false); return row is null ? null : new ScanTargetDisplayDTO { EntityId = entityId, Code = row.IndentNumber, Name = row.ItemName }; } public async Task> SearchAsync(string? term, LoginDTO login, CancellationToken ct) { var rows = await _dal.SearchAsync(term ?? string.Empty, login, ct).ConfigureAwait(false); return rows.Select(r => new ScanTargetDisplayDTO { EntityId = r.EntityId.ToString(), Code = r.IndentNumber, Name = r.ItemName }); } }