using GB5Shared.DTO.Framework.Login; using GB5Shared.ScanIdentifier; using WiDAL.CustomCode.ScanTarget; namespace WiBLL.ScanTarget; // Phase 1 resolver for the Scan-Identifier & Label Platform (GB5Shared/ScanIdentifier) — "MEMPLOYEE". // Reads MEMPLOYEE directly via EmployeeScanTargetDAL (same cross-module-SQL-without-ProjectReference // pattern already used this session) rather than the cross-host Hrms.Employeemaster.Get call the FE // uses today — a resolver needs a fast in-process lookup, not an HTTP round trip. public class EmployeeResolver : IScanTargetResolver { private readonly IEmployeeScanTargetDAL _dal; public EmployeeResolver(IEmployeeScanTargetDAL dal) => _dal = dal; public IEnumerable SupportedEntityTypes => new[] { "MEMPLOYEE" }; public async Task ExistsAsync(string entityId, LoginDTO login, CancellationToken ct) => int.TryParse(entityId, out var employeeId) && await _dal.GetByIdAsync(employeeId, login, ct).ConfigureAwait(false) is not null; public async Task GetDisplayAsync(string entityId, LoginDTO login, CancellationToken ct) { if (!int.TryParse(entityId, out var employeeId)) return null; var emp = await _dal.GetByIdAsync(employeeId, login, ct).ConfigureAwait(false); return emp is null ? null : new ScanTargetDisplayDTO { EntityId = entityId, Code = emp.Code, Name = emp.Name }; } 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.EmployeeId.ToString(), Code = r.Code, Name = r.Name }); } }