using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using SwDAL.DTO.ClientDatabaseKey; using SwDAL.Query.ClientDatabaseKey; namespace SwDAL.CustomCode.ClientDatabaseKey; public class ClientDatabaseKeyDAL : IClientDatabaseKeyDAL { private readonly IQueryExecutor _QueryExecutor; public ClientDatabaseKeyDAL(IQueryExecutor queryExecutor) => _QueryExecutor = queryExecutor; public async Task GetActiveByClientDb(int clientDbId, LoginDTO loginDTO, CancellationToken ct) => await _QueryExecutor.QuerySingleAsync( loginDTO, ClientDatabaseKeyQB.GET_ACTIVE_BY_CLIENTDB, new { ClientDbId = clientDbId, TenantId = loginDTO.ClientId }, cancellationToken: ct) .ConfigureAwait(false); public async Task GetById(int clientDatabaseKeyId, LoginDTO loginDTO, CancellationToken ct) => await _QueryExecutor.QuerySingleAsync( loginDTO, ClientDatabaseKeyQB.GET_BY_ID, new { ClientDatabaseKeyId = clientDatabaseKeyId, TenantId = loginDTO.ClientId }, cancellationToken: ct) .ConfigureAwait(false); public async Task Insert(ClientDatabaseKeyDTO dto, LoginDTO loginDTO, CancellationToken ct) => await _QueryExecutor.ExecuteAsync(loginDTO, ClientDatabaseKeyQB.INSERT, dto, cancellationToken: ct) .ConfigureAwait(false); public async Task SupersedeActive(int clientDbId, LoginDTO loginDTO, CancellationToken ct) => await _QueryExecutor.ExecuteAsync( loginDTO, ClientDatabaseKeyQB.SUPERSEDE_ACTIVE, new { ClientDbId = clientDbId, SupersededOn = DateTime.UtcNow, ModifiedById = loginDTO.UserId, ModifiedOn = DateTime.UtcNow, TenantId = loginDTO.ClientId }, cancellationToken: ct) .ConfigureAwait(false); public async Task Revoke(int clientDatabaseKeyId, LoginDTO loginDTO, CancellationToken ct) => await _QueryExecutor.ExecuteAsync( loginDTO, ClientDatabaseKeyQB.REVOKE, new { ClientDatabaseKeyId = clientDatabaseKeyId, ModifiedById = loginDTO.UserId, ModifiedOn = DateTime.UtcNow, TenantId = loginDTO.ClientId }, cancellationToken: ct) .ConfigureAwait(false); }