Files
Knots/Knots/Endpoints/Group/DeleteGroupEndpoint.cs
2026-03-26 16:38:04 +01:00

21 lines
564 B
C#

using FastEndpoints;
using Knots.DTO.Group;
namespace Knots.Endpoints.Group;
public class DeleteGroupEndpoint(KnotsDbContext db, AutoMapper.IMapper mapper) : Endpoint<DeleteGroupDto>
{
public override void Configure()
{
Delete("/groups");
AllowAnonymous();
}
public override async Task HandleAsync(DeleteGroupDto req, CancellationToken ct)
{
Models.Group? group = mapper.Map<Models.Group>(req);
db.Groups.Remove(group);
await db.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}
}