using AmpDAL.DTO.ApiParameter; using AmpDAL.Query.ApiParameter; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; namespace AmpDAL.CustomCode.ApiParameter; public class ApiParameterDAL(IQueryExecutor _qe) : IApiParameterDAL { public async Task> GetParameterListAsync(CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct) { var result = await _qe.QueryAsync( login, ApiParameterQB.GET_PARAMETER_LIST, new { TenantId = login.ClientId }).ConfigureAwait(false); return result.ToList(); } public async Task SaveParameterAsync(ApiParameterSaveDTO dto, LoginDTO login, CancellationToken ct) { return await _qe.ExecuteScalarAsync( login, ApiParameterQB.SAVE_PARAMETER, new { dto.ParameterId, dto.TenantId, dto.ApiId, dto.ApiOperationId, dto.Name, dto.InLocation, dto.DataType, dto.IsRequired, dto.Remarks, dto.SortOrder, dto.Status, dto.Version, dto.SourceType, dto.CreatedById, dto.CreatedOn, dto.ModifiedById, dto.ModifiedOn }).ConfigureAwait(false); } public async Task UpdateParameterAsync(ApiParameterSaveDTO dto, LoginDTO login, CancellationToken ct) { return await _qe.ExecuteScalarAsync( login, ApiParameterQB.UPDATE_PARAMETER, new { dto.ParameterId, dto.ApiOperationId, dto.Name, dto.InLocation, dto.DataType, dto.IsRequired, dto.Remarks, dto.SortOrder, dto.Status, dto.Version, dto.SourceType, dto.ModifiedById, dto.ModifiedOn }).ConfigureAwait(false); } public async Task GetParameterAsync(long parameterId, LoginDTO login, CancellationToken ct) => await _qe.QuerySingleAsync( login, ApiParameterQB.GET_PARAMETER, new { ParameterId = parameterId, TenantId = login.ClientId }).ConfigureAwait(false); public async Task> GetParameterSelectListAsync(CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct) { var result = await _qe.QueryAsync( login, ApiParameterQB.GET_PARAMETER_SELECT_LIST, new { TenantId = login.ClientId }).ConfigureAwait(false); return result.ToList(); } public async Task> GetPagedParameterList(int firstNumber, int maxResult, LoginDTO login, CancellationToken ct) { var result = await _qe.QueryAsync( login, ApiParameterQB.GET_PARAMETER_LIST_PAGED, new { TenantId = login.ClientId, FirstNumber = firstNumber, MaxResult = maxResult }).ConfigureAwait(false); return result.ToList(); } public async Task DeleteById(int parameterId, LoginDTO login, CancellationToken ct) => await _qe.ExecuteAsync( login, ApiParameterQB.DELETE_PARAMETER, new { ParameterId = parameterId, TenantId = login.ClientId }).ConfigureAwait(false); }