Files
Knots/Knots/Endpoints/Role/DeleteRoleEndpoint.cs
T

21 lines
552 B
C#

using FastEndpoints;
using Knots.DTO.Role;
namespace Knots.Endpoints.Role;
public class DeleteRoleEndpoint(KnotsDbContext db, AutoMapper.IMapper mapper) : Endpoint<DeleteRoleDto>
{
public override void Configure()
{
Delete("/roles");
AllowAnonymous();
}
public override async Task HandleAsync(DeleteRoleDto req, CancellationToken ct)
{
Models.Role? role = mapper.Map<Models.Role>(req);
db.Roles.Remove(role);
await db.SaveChangesAsync(ct);
await SendNoContentAsync(ct);
}
}