diff --git a/service/src/PingPong/Controllers/ScoreController.cs b/service/src/PingPong/Controllers/ScoreController.cs index f20dafd..1ccd651 100644 --- a/service/src/PingPong/Controllers/ScoreController.cs +++ b/service/src/PingPong/Controllers/ScoreController.cs @@ -15,7 +15,7 @@ public ScoreController(ScoreService scoreService) _scoreService = scoreService; } - [HttpGet(nameof(DeleteScores))] + [HttpDelete(nameof(DeleteScores))] public IActionResult DeleteScores() { try diff --git a/service/src/PingPong/Repositories/Score/IScoreRepository.cs b/service/src/PingPong/Repositories/Score/IScoreRepository.cs index d0d286a..a2f112f 100644 --- a/service/src/PingPong/Repositories/Score/IScoreRepository.cs +++ b/service/src/PingPong/Repositories/Score/IScoreRepository.cs @@ -8,5 +8,7 @@ public interface IScoreRepository void AddScores(PlayerDTO newScores); + void DeleteScores(); + } } diff --git a/service/src/PingPong/Repositories/Score/ScoreSQLiteRepository.cs b/service/src/PingPong/Repositories/Score/ScoreSQLiteRepository.cs index 0f63f1e..c98682f 100644 --- a/service/src/PingPong/Repositories/Score/ScoreSQLiteRepository.cs +++ b/service/src/PingPong/Repositories/Score/ScoreSQLiteRepository.cs @@ -80,11 +80,11 @@ public void DeleteScores() { using (SQLiteConnection connection = new SQLiteConnection(_sqlitePath)) { - connection.Open(); - string deleteQuery = "DELETE FROM PlayerItems"; - using (SQLiteCommand command = new SQLiteCommand(deleteQuery, connection)) + using (var conn = new SQLiteConnection(_sqlitePath)) { - command.ExecuteNonQuery(); + conn.Open(); + var cmd = new SQLiteCommand("DELETE FROM PlayerItems", conn); + cmd.ExecuteNonQuery(); } } }