using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using PayRollDAL.DTO.SAP; using PayRollDAL.Query.SAP; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace PayRollDAL.CustomeCode.SAP { public class ITDeclarationSapDAL : IITDeclarationSapDAL { private readonly IQueryExecutor _queryExecutor; public ITDeclarationSapDAL(IQueryExecutor queryExecutor) { _queryExecutor = queryExecutor; } public async Task> GetDeclarationsAsync( int declarationId, int employeeId, int periodId, LoginDTO login, CancellationToken ct) { string sql = login.DatabaseType switch { DBType.PostGre => ITDeclarationSapQB.GET_DECLARATIONS_FOR_SAP_PG, DBType.SQL => ITDeclarationSapQB.GET_DECLARATIONS_FOR_SAP, _ => throw new NotSupportedException( $"Database type {login.DatabaseType} is not supported for SAP integration.") }; var parameters = new { DeclarationId = declarationId, EmployeeId = employeeId, PeriodId = periodId }; return await _queryExecutor .QueryAsync(login, sql, parameters, cancellationToken: ct) .ConfigureAwait(false); } } }