using System.Data.Common; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using GB5Shared.ResponseStandard; using MMDAL.DTO.PartLevel; using MMDAL.Query.PartLevel; namespace MMDAL.CustomCode.PartLevel { public class PartDimensionDAL : IPartDimensionDAL { private readonly IQueryExecutor _QueryExecutor; public PartDimensionDAL(IQueryExecutor queryExecutor) => _QueryExecutor = queryExecutor; public async Task GetPartDimension(int partDimId, LoginDTO loginDTO, CancellationToken ct) => await _QueryExecutor .QuerySingleAsync(loginDTO, PartDimensionQB.GET_PARTDIMENSION, new { PartDimId = partDimId }, cancellationToken: ct) .ConfigureAwait(false); public async Task FindPartDimension(PartDimensionDTO dto, LoginDTO loginDTO, CancellationToken ct) => await _QueryExecutor .ExecuteScalarAsync(loginDTO, PartDimensionQB.FIND_PARTDIMENSION, new { dto.D1, dto.D2, dto.D3, dto.D4, dto.D5 }, cancellationToken: ct) .ConfigureAwait(false); public async Task> SavePartDimension( PartDimensionDTO dto, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct) { int rows = await _QueryExecutor .ExecuteAsync(loginDTO, PartDimensionQB.SAVE_PARTDIMENSION, dto, tx, cancellationToken: ct) .ConfigureAwait(false); return rows > 0 ? Result.Success("Part dimension saved.") : Result.Failure("Failed to save part dimension."); } public async Task> GetSelectListPartDimension( LoginDTO loginDTO, CancellationToken ct) => await _QueryExecutor .QueryAsync(loginDTO, PartDimensionQB.GET_SELECTLIST_PARTDIMENSION, null, cancellationToken: ct) .ConfigureAwait(false) ?? []; } }