feat: POST /worlds/{id}

This commit is contained in:
CyberL1 2024-02-06 13:04:20 +01:00
parent b84ddbceee
commit 400187a022

View File

@ -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<ActionResult<bool>> 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);
}
}
}