diff --git a/Refresh.GameServer/Database/GameDatabaseContext.Contests.cs b/Refresh.GameServer/Database/GameDatabaseContext.Contests.cs index 7852a653..aeb63332 100644 --- a/Refresh.GameServer/Database/GameDatabaseContext.Contests.cs +++ b/Refresh.GameServer/Database/GameDatabaseContext.Contests.cs @@ -23,6 +23,14 @@ public void CreateContest(GameContest contest) }); } + public void DeleteContest(GameContest contest) + { + this._realm.Write(() => + { + this._realm.Remove(contest); + }); + } + public GameContest? GetContestById(string? id) { if (id == null) return null; diff --git a/Refresh.GameServer/Endpoints/ApiV3/Admin/AdminContestApiEndpoints.cs b/Refresh.GameServer/Endpoints/ApiV3/Admin/AdminContestApiEndpoints.cs index 6b544b7d..37780c32 100644 --- a/Refresh.GameServer/Endpoints/ApiV3/Admin/AdminContestApiEndpoints.cs +++ b/Refresh.GameServer/Endpoints/ApiV3/Admin/AdminContestApiEndpoints.cs @@ -54,4 +54,17 @@ public ApiResponse CreateContest(RequestContext context, Gam return ApiContestResponse.FromOld(contest); } + + [ApiV3Endpoint("admin/contests/{id}", HttpMethods.Delete), MinimumRole(GameUserRole.Admin)] + [DocSummary("Deletes a contest.")] + [DocError(typeof(ApiNotFoundError), ApiNotFoundError.ContestMissingErrorWhen)] + public ApiOkResponse DeleteContest(RequestContext context, GameDatabaseContext database, string id) + { + GameContest? contest = database.GetContestById(id); + if (contest == null) return ApiNotFoundError.ContestMissingError; + + database.DeleteContest(contest); + + return new ApiOkResponse(); + } } \ No newline at end of file