34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Dapper;
|
|
using TaxBaik.Domain.Entities;
|
|
using TaxBaik.Domain.Interfaces;
|
|
|
|
namespace TaxBaik.Infrastructure.Repositories;
|
|
|
|
public class CommonCodeRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), ICommonCodeRepository
|
|
{
|
|
public async Task<IEnumerable<CommonCode>> GetByGroupAsync(string codeGroup, CancellationToken ct = default)
|
|
{
|
|
using var conn = Conn();
|
|
return await conn.QueryAsync<CommonCode>(
|
|
@"SELECT code_group as CodeGroup, code_value as CodeValue, code_name as CodeName, sort_order as SortOrder, is_active as IsActive
|
|
FROM common_codes
|
|
WHERE code_group = @CodeGroup AND is_active = TRUE
|
|
ORDER BY sort_order",
|
|
new { CodeGroup = codeGroup });
|
|
}
|
|
|
|
public async Task<IEnumerable<CommonCode>> GetAllActiveAsync(CancellationToken ct = default)
|
|
{
|
|
using var conn = Conn();
|
|
return await conn.QueryAsync<CommonCode>(
|
|
@"SELECT code_group as CodeGroup, code_value as CodeValue, code_name as CodeName, sort_order as SortOrder, is_active as IsActive
|
|
FROM common_codes
|
|
WHERE is_active = TRUE
|
|
ORDER BY code_group, sort_order");
|
|
}
|
|
}
|