Delete Player Endpoint

This commit is contained in:
glax 2025-05-26 01:52:50 +02:00
parent 4405c0349e
commit 59ade47bd7

View File

@ -28,6 +28,26 @@ public class ActionsController(Context databaseContext) : ApiController(typeof(A
}
}
[HttpDelete("Player/{steamId}")]
[ProducesResponseType<Player>(Status202Accepted)]
[ProducesResponseType<string>(Status500InternalServerError)]
public IActionResult DeletePlayer(ulong steamId)
{
if (databaseContext.Players.Find(steamId) is not { } player)
return NotFound();
try
{
databaseContext.Players.Remove(player);
databaseContext.SaveChanges();
return Accepted();
}
catch (Exception e)
{
Log.Error(e);
return StatusCode(Status500InternalServerError);
}
}
[HttpPost("Update/Player/{steamId}/All")]
[ProducesResponseType(Status200OK)]
[ProducesResponseType(Status404NotFound)]
@ -35,6 +55,7 @@ public class ActionsController(Context databaseContext) : ApiController(typeof(A
{
if (databaseContext.Players.Find(steamId) is not { } player)
return NotFound();
tracker.UpdatePlayer(databaseContext, player);
tracker.UpdateOwnedGamesPlayer(databaseContext, player);
tracker.UpdateGameTimesPlayer(databaseContext, player);