namespace TaxBaik.Application.Services;

using FluentValidation;
using TaxBaik.Domain.Entities;
using TaxBaik.Domain.Interfaces;

public class FaqService(IFaqRepository repository, IValidator<Faq> validator)
{
    public static readonly string[] Categories =
        ["기장세금신고", "부동산", "증여상속", "기타"];

    public async Task<IEnumerable<Faq>> GetActiveAsync(CancellationToken ct = default) =>
        await repository.GetActiveAsync(ct);

    public async Task<IEnumerable<Faq>> GetAllAsync(CancellationToken ct = default) =>
        await repository.GetAllAsync(ct);

    public async Task<Faq?> GetByIdAsync(int id, CancellationToken ct = default) =>
        await repository.GetByIdAsync(id, ct);

    public async Task<int> CreateAsync(Faq faq, CancellationToken ct = default)
    {
        validator.ValidateAndThrow(faq);
        return await repository.CreateAsync(faq, ct);
    }

    public async Task UpdateAsync(Faq faq, CancellationToken ct = default)
    {
        validator.ValidateAndThrow(faq);
        await repository.UpdateAsync(faq, ct);
    }

    public async Task DeleteAsync(int id, CancellationToken ct = default) =>
        await repository.DeleteAsync(id, ct);

}
