using qtc_api.Services.RoomService; namespace qtc_api.Controllers { [Route("api/rooms")] [ApiController] public class RoomsController : ControllerBase { public IRoomService _roomService; public IHubContext _hubContext; public RoomsController(IRoomService roomService, IHubContext hubContext) { _roomService = roomService; _hubContext = hubContext; } [HttpPost("create-room")] [Authorize(Roles = "Admin")] public async Task>> CreateRoom(string userId, RoomDto request) { var response = await _roomService.AddRoom(userId, request); await _hubContext.Clients.All.SendAsync("RefreshRoomList"); return Ok(response); } [HttpDelete("delete-room")] [Authorize(Roles = "Admin")] public async Task>> DeleteRoom(string roomId) { var response = await _roomService.DeleteRoom(roomId); await _hubContext.Clients.Group(roomId).SendAsync("RoomDeleted"); await _hubContext.Clients.All.SendAsync("RefreshRoomList"); return Ok(response); } [HttpGet("get-all-rooms")] [Authorize] public async Task>>> GetAllRooms() { var rooms = await _roomService.GetAllRooms(); return Ok(rooms); } } }