From 883298736fad988f7cb89f02a5061b24b15d9f16 Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Wed, 26 Aug 2020 21:25:32 +0200 Subject: [PATCH 1/3] Make endpoint make more sense --- ChaosBot/WebServer/App/CustomCommandApi.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ChaosBot/WebServer/App/CustomCommandApi.cs b/ChaosBot/WebServer/App/CustomCommandApi.cs index 97d351b..cec548e 100644 --- a/ChaosBot/WebServer/App/CustomCommandApi.cs +++ b/ChaosBot/WebServer/App/CustomCommandApi.cs @@ -57,21 +57,22 @@ namespace ChaosBot.WebServer.App } [HttpDelete] - [Route("{guildId}")] - public async Task DeleteCustomCommands([FromRoute]ulong guildId, [FromBody]CustomCommandRequest customCommandRequest) + [Route("{guildId}/{command}")] + public async Task DeleteCustomCommands([FromRoute]ulong guildId, [FromRoute]string command) { if (!CheckPermissions.GetResult(Request, guildId, out IActionResult result)) return result; await using ChaosbotContext dbContext = new ChaosbotContext(); - CustomCommand customCommand = new CustomCommand - { - DiscordGuildId = guildId, - Command = customCommandRequest.Command, - Type = customCommandRequest.Type, - Content = customCommandRequest.Content - }; + IQueryable customCommandQuery = dbContext.CustomCommands; + CustomCommand customCommand = customCommandQuery + .Where(cc => cc.DiscordGuildId == guildId) + .First(cc => cc.Command == command); + + if (customCommand == null) + return NotFound(); + dbContext.CustomCommands.Remove(customCommand); await dbContext.SaveChangesAsync(); From 5b6664544724d0ba52faa437ba68e1ac217be60d Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Wed, 26 Aug 2020 21:25:42 +0200 Subject: [PATCH 2/3] Update frontend --- ChaosBot/wwwroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChaosBot/wwwroot b/ChaosBot/wwwroot index 88776d6..0185381 160000 --- a/ChaosBot/wwwroot +++ b/ChaosBot/wwwroot @@ -1 +1 @@ -Subproject commit 88776d67515e8228b31500a9e5fde663fa73ef90 +Subproject commit 018538162a471a6a028149d27f4b3e992c3c7998 From 780db0d9573fff5b33bf6e79ba9d8f45ea89a7a1 Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Sun, 30 Aug 2020 11:47:50 +0200 Subject: [PATCH 3/3] Update frontend --- ChaosBot/wwwroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChaosBot/wwwroot b/ChaosBot/wwwroot index 0185381..5d42f98 160000 --- a/ChaosBot/wwwroot +++ b/ChaosBot/wwwroot @@ -1 +1 @@ -Subproject commit 018538162a471a6a028149d27f4b3e992c3c7998 +Subproject commit 5d42f98ba9efc9ff5f31f4fb4cd4f2f560584433