From 4bcdc99c8bf8457df6afa6632a6da77d3b25b4ee Mon Sep 17 00:00:00 2001 From: Jeas0001 Date: Mon, 24 Mar 2025 10:02:46 +0100 Subject: [PATCH] Updated so deleteUser gives the correct answer back in dbAccess and checks if the user could be saved to the db --- backend/Api/DBAccess/DBAccess.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/Api/DBAccess/DBAccess.cs b/backend/Api/DBAccess/DBAccess.cs index 19a46fd..b1f32d6 100644 --- a/backend/Api/DBAccess/DBAccess.cs +++ b/backend/Api/DBAccess/DBAccess.cs @@ -36,8 +36,11 @@ namespace Api.DBAccess } _context.Users.Add(user); - - return new OkObjectResult(await _context.SaveChangesAsync()); + bool saved = await _context.SaveChangesAsync() == 1; + + if (saved) { return new OkObjectResult(true); } + + return new ConflictObjectResult(new { message = "Could not save to databse" }); } public async Task Login(Login login) @@ -108,7 +111,7 @@ namespace Api.DBAccess } } _context.Users.Remove(user); - bool saved = await _context.SaveChangesAsync() == 1; + bool saved = await _context.SaveChangesAsync() >= 0; if (saved) { return new OkObjectResult(saved); }