Files
Knots/Knots/Endpoints/User/DeleteUserEndpoint.cs
T

21 lines
565 B
C#

using FastEndpoints;
using Knots.DTO.User;
using Microsoft.EntityFrameworkCore;
namespace Knots.Endpoints.User;
public class DeleteUserEndpoint(KnotsDbContext db, AutoMapper.IMapper mapper) : Endpoint <DeleteUserDto>
{
public override void Configure()
{
Delete ("/users/{@Id}");
}
public override async Task HandleAsync(DeleteUserDto req, CancellationToken ct)
{
Models.User? user = mapper.Map<Models.User>(req);
db.Users.Add(user);
await db.SaveChangesAsync(ct);
await SendNoContentAsync(ct);
}
}