using System.Linq; using System.Threading; using System.Threading.Tasks; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using WiDAL.Query.Promotion; namespace WiDAL.CustomCode.Promotion { public class WiHeaderCodeLookupDAL : IWiHeaderCodeLookupDAL { private readonly IQueryExecutor _qe; public WiHeaderCodeLookupDAL(IQueryExecutor qe) => _qe = qe; public async Task GetWiIdByCode(string wiCode, LoginDTO login, CancellationToken ct) { var rows = await _qe.QueryAsync(login, WiHeaderCodeLookupQB.GET_ID_BY_CODE, new { WiCode = wiCode, TenantId = login.ClientId }, cancellationToken: ct) .ConfigureAwait(false); var list = rows.ToList(); return list.Count > 0 ? list[0] : (int?)null; } } }