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