/// <summary>
        /// Updates a room
        /// </summary>
        /// <param name="roomName">The room name</param>
        /// <param name="request">The request to send</param>
        /// <returns>true if the call was successful</returns>
        /// <remarks>
        /// Auth required with scope 'admin_room'. https://www.hipchat.com/docs/apiv2/method/update_room
        /// </remarks>
        public bool UpdateRoom(string roomName, UpdateRoomRequest request)
        {
            using (JsonSerializerConfigScope())
            {
                var result = false;
                try
                {
                    HipchatEndpoints.UpdateRoomEndpoingFormat.Fmt(roomName)
                    .AddHipchatAuthentication()
                    .PutJsonToUrl(data: request, responseFilter: r =>
                    {
                        if (r.StatusCode == HttpStatusCode.NoContent)
                        {
                            result = true;
                        }
                    });
                }
                catch (Exception exception)
                {
                    if (exception is WebException)
                    {
                        throw ExceptionHelpers.WebExceptionHelper(exception as WebException, "admin_room");
                    }

                    throw ExceptionHelpers.GeneralExceptionHelper(exception, "Updateroom");
                }
                return(result);
            }
        }
Beispiel #2
0
        public async Task <UpdateRoomResponse> UpdateRoom(UpdateRoomRequest requestModel)
        {
            //Find and check if room exists in database
            var room = await FindById(requestModel.RoomId);

            //Check if room type exists
            if (!await _param.IsOfParamType(requestModel.RoomType, GlobalParams.ParamTypeRoomType))
            {
                throw new HttpStatusCodeException(HttpStatusCode.NotFound, "RoomService: RoomType is not valid");
            }

            //Update room with new information
            room = UpdateRoomRequest.UpdateToRoom(room, requestModel);


            //Update to database
            room = await _repoWrapper.Room.UpdateAsync(room, room.RoomId);

            var equipments =
                (List <Equipment>) await _repoWrapper.Equipment.FindAllAsyncWithCondition(e => e.RoomId == room.RoomId);

            List <int> equipmentIds = null;

            if (EnumerableExtensions.Any(equipments))
            {
                equipmentIds = equipments.Select(e => e.EquipmentId).ToList();
            }

            return(UpdateRoomResponse.ResponseFromRoom(room, equipmentIds));
        }
Beispiel #3
0
        public void Update(Room Room)
        {
            var request = new UpdateRoomRequest();

            request.Room = Room;
            var response = HttpPost <UpdateRoomRequest>("api/room/update", request, MediaType.Json);
        }
Beispiel #4
0
        private static void UpdateRoom()
        {
            UpdateRoomRequest request = new UpdateRoomRequest(1, name: "RenamedTestRoom", notes: "Renamed the test room");
            Node updatedRoomNode      = dc.Nodes.UpdateRoom(request);

            Console.WriteLine("Updated room id: " + updatedRoomNode.Id + "; Name: " + updatedRoomNode.Name);
        }
Beispiel #5
0
        public override bool SaveItem(bool copyCurrent = false)
        {
            var json = JsonView?.Text.ToString();

            if (!string.IsNullOrEmpty(json))
            {
                try
                {
                    var room = JsonConvert.DeserializeObject <Room>(json);
                    if (copyCurrent)
                    {
                        var roomRequest = new CreateRoomRequest(room.Name += "-copy");
                        STClient.CreateRoom(room.LocationId.ToString(), roomRequest);
                    }
                    else
                    {
                        var roomRequest = new UpdateRoomRequest(room.Name);
                        STClient.UpdateRoom(room.LocationId.ToString(), room.RoomId.ToString(), roomRequest);
                    }
                    RefreshScreen();
                }
                catch (SmartThingsNet.Client.ApiException exp)
                {
                    ShowErrorMessage($"Error {exp.ErrorCode}{Environment.NewLine}{exp.Message}");
                }
                catch (Exception exp)
                {
                    ShowErrorMessage($"Error {exp.Message}");
                }
            }
            return(true);
        }
        public async Task <Room> UpdateRoomAsync(string roomId, UpdateRoomRequest request)
        {
            string url = _baseApiAddress + $"rooms/{roomId}";

            var content = new StringContent(JsonConvert.SerializeObject(request));

            return(await HttpClient.PutAsync <Room>(url, content));
        }
Beispiel #7
0
        internal static ApiUpdateRoomRequest ToApiUpdateRoomRequest(UpdateRoomRequest updateRoomRequest)
        {
            ApiUpdateRoomRequest apiUpdateRoomRequest = new ApiUpdateRoomRequest {
                Name  = updateRoomRequest.Name,
                Quota = updateRoomRequest.Quota,
                Notes = updateRoomRequest.Notes
            };

            return(apiUpdateRoomRequest);
        }
Beispiel #8
0
        public void CanUpdateRoom()
        {
            var request = new UpdateRoomRequest
            {
                Name  = "My new Room",
                Owner = _owner
            };

            var result = _client.UpdateRoom(_createdRoomId, request);

            Assert.True(result);
        }
Beispiel #9
0
        public async Task <Room> UpdateRoomAsync(string roomId, UpdateRoomRequest request)
        {
            string url = _baseApiAddress + $"rooms/{roomId}";

#if __IOS__ || __ANDROID__ || NET45
            var content = new StringContent(JsonConvert.SerializeObject(request));
#endif
#if NETFX_CORE
            var content = new HttpStringContent(JsonConvert.SerializeObject(request));
#endif

            return(await HttpClient.PutAsync <Room>(url, content));
        }
        public async Task <ActionResult <UpdateRoomResponse> > UpdateRoom(UpdateRoomRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!RoomStatus.IsRoomStatus(request.RoomStatus))
            {
                return(BadRequest("RoomsController: RoomStatus is invalid. Must be: " + RoomStatus.ListAllStatuses()));
            }

            return(await _room.UpdateRoom(request));
        }
Beispiel #11
0
    // Use this for initialization
    private void Awake()
    {
        //MonkeyPanel = transform.Find("MonkeyPanel");
        //FishPanel = transform.Find("FishPanel");

        //localPlayerUsername = MonkeyPanel.Find("Username").GetComponent<Text>();
        //localPlayerTotalCount = MonkeyPanel.Find("TotalCount").GetComponent<Text>();
        //localPlayerWinCount = MonkeyPanel.Find("WinCount").GetComponent<Text>();
        //enemyPlayerUsername = FishPanel.Find("Username").GetComponent<Text>();
        //enemyPlayerTotalCount = FishPanel.Find("TotalCount").GetComponent<Text>();
        //enemyPlayerWinCount = FishPanel.Find("WinCount").GetComponent<Text>();

        FishSeats   = new SeatItem[GameFacade.FISH_NUM];
        MonkeySeats = new SeatItem[GameFacade.MONKEY_NUM];

        startButton = transform.Find("StartButton");
        exitButton  = transform.Find("ExitButton");
        sendButton  = transform.Find("InputPanel/SendButton");
        inputField  = transform.Find("InputPanel/InputField").GetComponent <InputField>();

        startButton.GetComponent <Button>().onClick.AddListener(OnStartClick);
        exitButton.GetComponent <Button>().onClick.AddListener(OnExitClick);
        sendButton.GetComponent <Button>().onClick.AddListener(OnSendClick);
        inputField.onEndEdit.AddListener(x => OnSendClick());


        OtherPlayerChatMsgItem = Resources.Load <GameObject>("UIItem/Chat/OtherPlayerChatMsgItem");
        LocalPlayerChatMsgItem = Resources.Load <GameObject>("UIItem/Chat/LocalPlayerChatMsgItem");
        ChangeSeatItem         = Resources.Load <GameObject>("UIItem/ChangeSeatItem");


        quitRoomRequest   = GetComponent <QuitRoomRequest>();
        startGameRequest  = GetComponent <StartGameRequest>();
        roomChatRequest   = GetComponent <RoomChatRequest>();
        changeSeatRequest = GetComponent <ChangeSeatRequest>();
        updateRoomRequest = GetComponent <UpdateRoomRequest>();

        FishSeats   = transform.Find("FishPlayerPanel").GetComponentsInChildren <SeatItem>();
        MonkeySeats = transform.Find("MonkeyPlayerPanel").GetComponentsInChildren <SeatItem>();
        for (int i = 0; i < GameFacade.FISH_NUM; i++)
        {
            FishSeats[i].index = i;
        }
        for (int i = 0; i < GameFacade.MONKEY_NUM; i++)
        {
            MonkeySeats[i].index = i + GameFacade.FISH_NUM;
        }
    }
        public void ToApiUpdateRoomRequest()
        {
            // ARRANGE
            ApiUpdateRoomRequest expected = FactoryRoom.ApiUpdateRoomRequest;

            UpdateRoomRequest param = new UpdateRoomRequest(12)
            {
                Name  = expected.Name,
                Quota = expected.Quota,
                Notes = expected.Notes
            };

            // ACT
            ApiUpdateRoomRequest actual = RoomMapper.ToApiUpdateRoomRequest(param);

            // ASSERT
            Assert.Equal(expected, actual, new ApiUpdateRoomRequestComparer());
        }
Beispiel #13
0
        public Node UpdateRoom(UpdateRoomRequest request)
        {
            _client.Executor.CheckApiServerVersion();

            #region Parameter Validation

            request.MustNotNull(nameof(request));
            request.Name.MustNotNullOrEmptyOrWhitespace(nameof(request.Name));
            request.Id.MustPositive(nameof(request.Id));
            request.Quota.NullableMustNotNegative(nameof(request.Quota));

            #endregion

            ApiUpdateRoomRequest apiUpdateRoomRequest = RoomMapper.ToApiUpdateRoomRequest(request);
            IRestRequest         restRequest          = _client.Builder.PutRoom(request.Id, apiUpdateRoomRequest);
            ApiNode result = _client.Executor.DoSyncApiCall <ApiNode>(restRequest, RequestType.PutRoom);
            return(NodeMapper.FromApiNode(result));
        }
Beispiel #14
0
 public void delete(UpdateRoomRequest request)
 {
     try
     {
         var response = new UpdateRoomResponse();
         var bc       = new RoomComponent();
         bc.Update(request.Room);
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
        private async Task SaveClick()
        {
            if (ToSave.RoomId == 0)
            {
                var toCreate = new CreateRoomRequest()
                {
                    Name = ToSave.Name,
                };
                await RoomService.CreateAsync(toCreate);
            }
            else
            {
                var toUpdate = new UpdateRoomRequest()
                {
                    RoomId = ToSave.RoomId,
                    Name   = ToSave.Name,
                };
                await RoomService.EditAsync(toUpdate);
            }

            CancelClick();
            await ReloadData();
        }
Beispiel #16
0
        public async Task UpdateRoom_ValidRequest_AddedToDatabase()
        {
            var request = new UpdateRoomRequest()
            {
                Name = "Test updated",
            };

            var club = new Club()
            {
                ClubId = Guid.NewGuid()
            };

            var room = new Room()
            {
                ClubId = club.ClubId,
                Name   = "Test"
            };

            using (var context = _factory.CreateContext())
            {
                context.Clubs.Add(club);
                context.Rooms.Add(room);
                context.SaveChanges();
            }

            await _mutations.UpdateRoomAsync(room.RoomId, request);

            using (var context = _factory.CreateContext())
            {
                var roomdb = context.Rooms.FirstOrDefault(room => room.Name == request.Name);
                Assert.That(roomdb, Is.Not.Null);
                Assert.That(context.Rooms.Count(), Is.EqualTo(1));
            }

            await _publish.Received(1).Publish(Arg.Any <RoomUpdatedEvent>());
        }
Beispiel #17
0
        public async Task <Room> UpdateRoomAsync(Guid id, UpdateRoomRequest request)
        {
            var item = await _context.Rooms.FindAsync(id);

            if (item == null)
            {
                throw new QueryException(
                          ErrorBuilder.New()
                          .SetMessage("The provided id is unknown.")
                          .SetCode("ID_UNKNOWN")
                          .Build());
            }
            await IsAdminIn(item.ClubId);

            _mapper.Map(request, item);
            _context.Rooms.Update(item);

            var @event = _mapper.Map <RoomUpdatedEvent>(item);
            await _eventService.SaveEventAndDbContextChangesAsync(@event);

            await _eventService.PublishEventAsync(@event);

            return(item);
        }
Beispiel #18
0
        public async Task UpdateRoom_RoomDoesNotExist_Fails()
        {
            var request = new UpdateRoomRequest()
            {
                Name = "Test updated",
            };

            var club = new Club()
            {
                ClubId = Guid.NewGuid()
            };

            var room = new Room()
            {
                ClubId = club.ClubId,
                Name   = "Test"
            };

            using (var context = _factory.CreateContext())
            {
                context.Clubs.Add(club);
                context.Rooms.Add(room);
                context.SaveChanges();
            }

            Assert.ThrowsAsync <QueryException>(async() => await _mutations.UpdateRoomAsync(Guid.NewGuid(), request));

            using (var context = _factory.CreateContext())
            {
                var roomdb = context.Rooms.FirstOrDefault(roomdb => roomdb.Name == room.Name);
                Assert.That(roomdb, Is.Not.Null);
                Assert.That(context.Rooms.Count(), Is.EqualTo(1));
            }

            await _publish.Received(0).Publish(Arg.Any <RoomUpdatedEvent>());
        }
Beispiel #19
0
 /// <summary>
 /// Updates a room
 /// </summary>
 /// <param name="roomId">The room id</param>
 /// <param name="request">The request to send</param>
 /// <returns>true if the call was successful</returns>
 /// <remarks>
 /// Auth required with scope 'admin_room'. https://www.hipchat.com/docs/apiv2/method/update_room
 /// </remarks>
 public bool UpdateRoom(int roomId, UpdateRoomRequest request)
 {
     return(UpdateRoom(roomId.ToString(CultureInfo.InvariantCulture), request));
 }
 /// <summary>
 ///  修改房间
 ///
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public UpdateRoomResponse UpdateRoom(UpdateRoomRequest request)
 {
     return(new UpdateRoomExecutor().Client(this).Execute <UpdateRoomResponse, UpdateRoomResult, UpdateRoomRequest>(request));
 }
 /// <summary>
 ///  修改房间
 ///
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <UpdateRoomResponse> UpdateRoom(UpdateRoomRequest request)
 {
     return(await new UpdateRoomExecutor().Client(this).Execute <UpdateRoomResponse, UpdateRoomResult, UpdateRoomRequest>(request).ConfigureAwait(false));
 }
 public async Task UpdateRoomAsync(UpdateRoomRequest RoomRequest)
 {
     var RoomRequestJson = new StringContent(JsonSerializer.Serialize(RoomRequest), Encoding.UTF8, "application/json");
     await HttpClient.PutAsync($"room", RoomRequestJson);
 }
Beispiel #23
0
 public IObservable <Room> UpdateRoom(string roomId, UpdateRoomRequest request)
 {
     return(_apiService.UpdateRoomAsync(roomId, request).ToObservable());
 }
 public Room UpdateRoom(string locationId, string roomId, UpdateRoomRequest roomRequest)
 {
     return(_roomsApi.UpdateRoom(_accessToken, locationId, roomId, roomRequest));
 }
Beispiel #25
0
 public async Task <RoomDto> EditAsync(UpdateRoomRequest room)
 {
     return((await _httpService.HttpPutAsync <UpdateRoomResponse>("rooms", room)).Room);
 }