From 400187a02244537eaf05377909afacb93b4ce3ac Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Tue, 6 Feb 2024 13:04:20 +0100 Subject: [PATCH] feat: POST /worlds/{id} --- .../Controllers/WorldsController.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs index 75708cd..12b6c2c 100644 --- a/Minecraft-Realms-Emulator/Controllers/WorldsController.cs +++ b/Minecraft-Realms-Emulator/Controllers/WorldsController.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using Minecraft_Realms_Emulator.Data; using Minecraft_Realms_Emulator.Entities; +using System.Diagnostics.Eventing.Reader; namespace Minecraft_Realms_Emulator.Controllers { @@ -144,5 +145,22 @@ namespace Minecraft_Realms_Emulator.Controllers return Ok(true); } + + [HttpPost("{id}")] + public async Task> UpdateWorld(int id, WorldCreate body) + { + var worlds = await _context.Worlds.ToListAsync(); + + var world = worlds.Find(w => w.Id == id); + + if (world == null) return NotFound("World not found"); + + world.Name = body.Name; + world.Motd = body.Description; + + _context.SaveChanges(); + + return Ok(true); + } } }