Initial commit

This commit is contained in:
2026-05-05 10:39:43 +02:00
commit b590ecdc35
87 changed files with 3934 additions and 0 deletions
@@ -0,0 +1,34 @@
using FastEndpoints;
using MetaCourse.Api.Data;
using Microsoft.EntityFrameworkCore;
namespace MetaCourse.Api.Endpoints.Topics;
public class DeleteTopicRequest
{
public Guid Id { get; set; }
}
public class DeleteTopicEndpoint(AppDbContext db) : Endpoint<DeleteTopicRequest>
{
public override void Configure()
{
Delete("api/topics/{id}");
AllowAnonymous();
Summary(s => s.Summary = "Supprime un sujet et ses associations de ressources");
}
public override async Task HandleAsync(DeleteTopicRequest req, CancellationToken ct)
{
var topic = await db.Topics.FirstOrDefaultAsync(t => t.Id == req.Id, ct);
if (topic is null)
{
await SendNotFoundAsync(ct);
return;
}
db.Topics.Remove(topic);
await db.SaveChangesAsync(ct);
await SendNoContentAsync(ct);
}
}