using System.Linq; using System.Threading; using System.Threading.Tasks; using GB5Shared.QueryExecutor; using PromotionExchangeDAL.Common; using PromotionExchangeDAL.DTO; using PromotionExchangeDAL.Query; namespace PromotionExchangeDAL.CustomCode; public class ExchangePartyDAL : IExchangePartyDAL { private readonly IQueryExecutor _qe; private readonly IPromotionExchangeSystemContext _systemContext; public ExchangePartyDAL(IQueryExecutor qe, IPromotionExchangeSystemContext systemContext) { _qe = qe; _systemContext = systemContext; } public async Task GetByApiKeyHash(string apiKeyHash, CancellationToken ct) { var login = _systemContext.GetSystemLogin(); var rows = await _qe.QueryAsync(login, ExchangePartyQB.GET_BY_API_KEY_HASH, new { ApiKeyHash = apiKeyHash }, cancellationToken: ct).ConfigureAwait(false); return rows.FirstOrDefault(); } public async Task GetByEnvironmentCode(string environmentCode, CancellationToken ct) { var login = _systemContext.GetSystemLogin(); var rows = await _qe.QueryAsync(login, ExchangePartyQB.GET_BY_ENVIRONMENT_CODE, new { EnvironmentCode = environmentCode }, cancellationToken: ct).ConfigureAwait(false); return rows.FirstOrDefault(); } }