namespace Netina.Repository.Handlers.Faqs;

public class CreateFaqCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper)
    : IRequestHandler<CreateFaqCommand, bool>
{
    public async Task<bool> Handle(CreateFaqCommand request, CancellationToken cancellationToken)
    {
        var faq = new BaseFaq
        {
            Faqs = request.Faqs,
            Slug = request.Slug,
            Title = request.Title
        };
        await martenRepositoryWrapper.SetRepository<BaseFaq>()
            .AddOrUpdateEntityAsync(faq, cancellationToken);
        return true;
    }
}