using FastEndpoints;
using TaxBaik.Application.Services;

namespace TaxBaik.Web.Endpoints.Blog;

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

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

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

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