mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-25 23:18:44 -07:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user