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,33 @@
using AutoMapper;
using FastEndpoints;
using MetaCourse.Api.Data;
using MetaCourse.Api.DTOs.Users;
using Microsoft.EntityFrameworkCore;
namespace MetaCourse.Api.Endpoints.Users;
public class GetUserRequest
{
public Guid Id { get; set; }
}
public class GetUserEndpoint(AppDbContext db, AutoMapper.IMapper mapper) : Endpoint<GetUserRequest, GetUserDto>
{
public override void Configure()
{
Get("api/users/{id}");
AllowAnonymous();
Summary(s => s.Summary = "Récupère le profil d'un utilisateur");
}
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
{
var user = await db.Users.AsNoTracking().FirstOrDefaultAsync(u => u.Id == req.Id, ct);
if (user is null)
{
await SendNotFoundAsync(ct);
return;
}
await SendOkAsync(mapper.Map<GetUserDto>(user), ct);
}
}