Delete Player Endpoint
This commit is contained in:
parent
4405c0349e
commit
59ade47bd7
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user