using Indotalent.Infrastructure.Database;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace Indotalent.Features.Serilogs.Database;




public record DeleteSerilogLogsAllCommand() : IRequest<bool>;

public class DeleteSerilogLogsHandler :
    IRequestHandler<DeleteSerilogLogsAllCommand, bool>
{
    private readonly AppDbContext _context;

    public DeleteSerilogLogsHandler(AppDbContext context)
    {
        _context = context;
    }


    public async Task<bool> Handle(DeleteSerilogLogsAllCommand request, CancellationToken cancellationToken)
    {
        await _context.Database.ExecuteSqlRawAsync("TRUNCATE TABLE SerilogLogs", cancellationToken);
        return true;
    }
}