fix new user id

This commit is contained in:
neroduckale 2024-01-12 04:14:28 +05:00
parent 097101bce8
commit 3e12567937
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 399E73062E1A3667

View file

@ -46,7 +46,7 @@ app.MapDelete("/api/users/{id:int}", async (int id, DatabaseHandler db) => {
return Results.Json(user);
}); //WORKS
app.MapPost("/api/users", async (NewUser newuser, DatabaseHandler db) => {
User user = new User(newuser.nickname, db.users.Count() + 1, newuser.mast);
User user = new User(newuser.nickname, db.users.OrderBy(p => p.id).Last().id + 1, newuser.mast);
await db.users.AddAsync(user);
await db.SaveChangesAsync();
return user;