using FastEndpoints;
using TaxBaik.Application.Services;

namespace TaxBaik.Web.Endpoints.Blog;

public class DeleteEndpoint : Endpoint<EmptyRequest, EmptyResponse>
{
    private readonly BlogService _blogService;

    public DeleteEndpoint(BlogService blogService)
    {
        _blogService = blogService;
    }

    public override void Configure()
    {
        Delete("/api/blog/{id}");
        Policies("Bearer");
    }

    public override async Task HandleAsync(EmptyRequest _, CancellationToken ct)
    {
        var id = Route<int>("id");
        await _blogService.ArchiveAsync(id);
        await SendAsync(new EmptyResponse(), 204, cancellation: ct);
    }
}
