feat: add delete functionality for exercises and routines

This commit is contained in:
2026-01-31 00:18:30 +01:00
parent 81d6b70673
commit 8300331276
5 changed files with 107 additions and 41 deletions

View File

@@ -160,6 +160,23 @@ internal static class RoutineEndpoints
.WithSummary("Update routine")
.WithDescription("Updates routine metadata and exercise ordering.");
group.MapDelete("/users/{userId}/routines/{routineId:int}", async (string userId, int routineId, AppDbContext db) =>
{
var user = await UserProvisioning.EnsureUserAsync(db, userId);
var routine = await db.Routines.FirstOrDefaultAsync(r => r.Id == routineId && r.UserId == user.Id);
if (routine is null)
{
return Results.NotFound();
}
db.Routines.Remove(routine);
await db.SaveChangesAsync();
return Results.NoContent();
})
.WithSummary("Delete routine")
.WithDescription("Deletes a routine and its associated data for the specified user.");
return group;
}
}