public IActionResult Update([FromBody] UpdateRoomDto dto)
 {
     try
     {
         var result = _repo.Update(dto);
         //_hub.RefreshRoom("Refresh Room");
         _hub.Clients.All.SendAsync("RefreshRoom", "Refresh Room");
         return(Ok(result));
     }
     catch (Exception ex)
     {
         logger.Error($"An error occured: {ex.Message}");
         return(BadRequest(ex.Message));
     }
 }
Beispiel #2
0
        public RoomDto Update(UpdateRoomDto dto)
        {
            var oldRoom = GetByGuid(dto.RoomID);

            if (oldRoom == null || oldRoom.RoomID == Guid.Empty || oldRoom.OwnerID == Guid.Empty)
            {
                throw new InvalidOperationException($"Room with ID {dto.RoomID} does not exist");
            }

            var newRoom = new RoomDto
            {
                RoomID    = dto.RoomID,
                RoomName  = dto.RoomName,
                OwnerID   = oldRoom.OwnerID,
                canVote   = dto.canVote,
                showVotes = dto.showVotes,
            };

            _roomCache.SetCache("Room_" + newRoom.RoomID.ToString().ToLowerInvariant(), new List <RoomDto> {
                newRoom
            });

            return(newRoom);
        }