49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using TaxBaik.Domain.Entities;
|
|
using TaxBaik.Domain.Interfaces;
|
|
|
|
namespace TaxBaik.Application.Services;
|
|
|
|
public class CommonCodeService(ICommonCodeRepository commonCodeRepository)
|
|
{
|
|
public async Task<IEnumerable<string>> GetAllGroupsAsync(CancellationToken ct = default)
|
|
{
|
|
return await commonCodeRepository.GetAllGroupsAsync(ct);
|
|
}
|
|
|
|
public async Task<IEnumerable<CommonCode>> GetByGroupAsync(string codeGroup, CancellationToken ct = default)
|
|
{
|
|
return await commonCodeRepository.GetByGroupAsync(codeGroup, ct);
|
|
}
|
|
|
|
public async Task<IEnumerable<CommonCode>> GetAllActiveAsync(CancellationToken ct = default)
|
|
{
|
|
return await commonCodeRepository.GetAllActiveAsync(ct);
|
|
}
|
|
|
|
public async Task<CommonCode?> GetAsync(string codeGroup, string codeValue, CancellationToken ct = default)
|
|
{
|
|
return await commonCodeRepository.GetAsync(codeGroup, codeValue, ct);
|
|
}
|
|
|
|
public async Task UpsertAsync(CommonCode code, CancellationToken ct = default)
|
|
{
|
|
Normalize(code);
|
|
await commonCodeRepository.UpsertAsync(code, ct);
|
|
}
|
|
|
|
public async Task DeleteAsync(string codeGroup, string codeValue, CancellationToken ct = default)
|
|
{
|
|
await commonCodeRepository.DeleteAsync(codeGroup.Trim(), codeValue.Trim(), ct);
|
|
}
|
|
|
|
private static void Normalize(CommonCode code)
|
|
{
|
|
code.CodeGroup = code.CodeGroup.Trim();
|
|
code.CodeValue = code.CodeValue.Trim();
|
|
code.CodeName = code.CodeName.Trim();
|
|
}
|
|
}
|