Changements dans le Group Model + endpoints Patch des Groupes et Users

This commit is contained in:
oistig
2026-03-19 16:18:52 +01:00
parent 24613de57c
commit 7c2e77ed99
17 changed files with 226 additions and 14 deletions
@@ -0,0 +1,29 @@
using FastEndpoints;
using Knots.DTO.Group;
using Microsoft.EntityFrameworkCore;
namespace Knots.Endpoints.Group;
public class PatchGroupProfilePictureEndpoint(KnotsDbContext knotsDbContext) : Endpoint<UpdateGroupProfilePictureDto>
{
public override void Configure()
{
Patch("/groups/{@Id}/profilePicture/", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(UpdateGroupProfilePictureDto req, CancellationToken ct)
{
Models.Group? databaseGroup = await knotsDbContext.Groups.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
if (databaseGroup is null)
{
await Send.NotFoundAsync(ct);
return;
}
databaseGroup.ProfilePicture = req.ProfilePicture;
await knotsDbContext.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}
}