Enhance room role management: refactor role granting logic, add role invitation endpoints, and improve role handling in RoomsController and AdminController

This commit is contained in:
Alexa
2026-06-06 20:33:08 +03:00
parent 9b39c2e8e4
commit eb2fb0e1f1
6 changed files with 326 additions and 25 deletions
@@ -350,6 +350,7 @@ public class AdminController(
{
r.Id,
r.Name,
r.ImageName,
r.IsAGRoom,
r.IsDormRoom,
r.CreatorPlayerId,
@@ -1032,6 +1033,12 @@ public class AdminController(
if (body.PlayerId <= 0) return BadRequest("missing player");
if (body.Role is < 0 or > 2) return BadRequest("invalid role");
var oldRoles = await db.RoomRoles
.Where(r => r.RoomId == id && r.PlayerId == body.PlayerId && r.Role != body.Role)
.ToListAsync();
if (oldRoles.Count > 0)
db.RoomRoles.RemoveRange(oldRoles);
var existing = await db.RoomRoles.FirstOrDefaultAsync(r =>
r.RoomId == id && r.PlayerId == body.PlayerId && r.Role == body.Role);
if (existing is null)