using System.Data.Common; using EntitlementDAL.DTOs; using EntitlementDAL.Interfaces; using EntitlementDAL.QueryBuilders; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; namespace EntitlementDAL.Implementations; public class MenuSetMapDAL : IMenuSetMapDAL { private readonly IQueryExecutor _QueryExecutor; public MenuSetMapDAL(IQueryExecutor queryExecutor) => _QueryExecutor = queryExecutor; public async Task> GetListAsync(LoginDTO login, CancellationToken ct) => await _QueryExecutor.QueryAsync( login, MenuSetMapQB.GET_LIST, cancellationToken: ct).ConfigureAwait(false) ?? Enumerable.Empty(); public async Task GetByIdAsync(int featureMenuSetMapId, LoginDTO login, CancellationToken ct) => await _QueryExecutor.QuerySingleAsync( login, MenuSetMapQB.GET_BY_ID, new { FeatureMenuSetMapId = featureMenuSetMapId }, cancellationToken: ct).ConfigureAwait(false); public async Task GetByFeatureAndMenuSetAsync(int featureId, int menuSetId, LoginDTO login, CancellationToken ct) => await _QueryExecutor.QuerySingleAsync( login, MenuSetMapQB.GET_BY_FEATURE_AND_MENUSET, new { FeatureId = featureId, MenuSetId = menuSetId }, cancellationToken: ct).ConfigureAwait(false); public async Task SaveAsync(FeatureMenuSetMapDTO dto, LoginDTO login, DbTransaction tx, CancellationToken ct) => await _QueryExecutor.ExecuteAsync(login, MenuSetMapQB.INSERT, dto, tx, cancellationToken: ct).ConfigureAwait(false); public async Task UpdateAsync(FeatureMenuSetMapDTO dto, LoginDTO login, DbTransaction tx, CancellationToken ct) => await _QueryExecutor.ExecuteAsync(login, MenuSetMapQB.UPDATE, dto, tx, cancellationToken: ct).ConfigureAwait(false); public async Task DeleteAsync(int featureMenuSetMapId, LoginDTO login, DbTransaction tx, CancellationToken ct) => await _QueryExecutor.ExecuteAsync(login, MenuSetMapQB.DELETE, new { FeatureMenuSetMapId = featureMenuSetMapId }, tx, cancellationToken: ct).ConfigureAwait(false); }