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,39 @@
using AutoMapper;
using FastEndpoints;
using MetaCourse.Api.Data;
using MetaCourse.Api.DTOs.Topics;
using Microsoft.EntityFrameworkCore;
namespace MetaCourse.Api.Endpoints.Topics;
public class GetTopicRequest
{
public Guid Id { get; set; }
}
public class GetTopicEndpoint(AppDbContext db, AutoMapper.IMapper mapper) : Endpoint<GetTopicRequest, GetTopicDto>
{
public override void Configure()
{
Get("api/topics/{id}");
AllowAnonymous();
Summary(s => s.Summary = "Récupère un sujet avec ses ressources");
}
public override async Task HandleAsync(GetTopicRequest req, CancellationToken ct)
{
var topic = await db.Topics
.AsNoTracking()
.Include(t => t.TopicResources.OrderBy(tr => tr.Position))
.ThenInclude(tr => tr.Resource)
.FirstOrDefaultAsync(t => t.Id == req.Id, ct);
if (topic is null)
{
await SendNotFoundAsync(ct);
return;
}
await SendOkAsync(mapper.Map<GetTopicDto>(topic), ct);
}
}