private void BtnUpdateRoom_Click(object sender, EventArgs e)
        {
            UpdateRoom updateRoom = new UpdateRoom();

            this.Hide();
            updateRoom.Show();
        }
Example #2
0
        public void ShouldFailUpdatingRoom()
        {
            var input        = new Room(0, 0, "test", RoomType.Call);
            var mockRoomRepo = new Mock <IRoomRepository>();

            mockRoomRepo.Setup(m => m.Update(It.IsAny <Room>())).Returns(-1);
            var res = new UpdateRoom(mockRoomRepo.Object, input).Execute();

            Assert.AreEqual(-1, res);
        }
Example #3
0
        public void ShouldUpdateRoom()
        {
            var input        = new Room(0, 0, "test", RoomType.Call);
            var mockRoomRepo = new Mock <IRoomRepository>();

            mockRoomRepo.Setup(m => m.Update(input)).Returns(0);
            var res = new UpdateRoom(mockRoomRepo.Object, input).Execute();

            Assert.AreEqual(0, res);
        }
Example #4
0
        public IActionResult Update([FromBody] Room room)
        {
            var res = new UpdateRoom(Repository, room).Execute();

            if (res == -1)
            {
                return(Conflict());
            }
            return(Ok(res));
        }
Example #5
0
        public virtual IHttpActionResult Put(long id, [FromBody] UpdateRoom value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Room model = repository.GetByID(id);

            try
            {
                model.Update(value);
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            repository.Update(model);
            return(Content(HttpStatusCode.NoContent, ""));
        }
Example #6
0
        private void Client_UpdateRoom(Room obj)
        {
            UpdateRoom?.Invoke(obj);

            switch (obj.State)
            {
            case RoomState.Waiting:
                WaitingRooms[obj.Id] = obj;
                break;

            case RoomState.Dueling:
                if (WaitingRooms.ContainsKey(obj.Id))
                {
                    WaitingRooms.Remove(obj.Id);
                }
                if (DuelingRooms.ContainsKey(obj.Id))
                {
                    DuelingRooms[obj.Id] = obj;
                }
                else
                {
                    DuelingRooms.Add(obj.Id, obj);
                }
                break;

            case RoomState.Finished:
                if (WaitingRooms.ContainsKey(obj.Id))
                {
                    WaitingRooms.Remove(obj.Id);
                }
                if (DuelingRooms.ContainsKey(obj.Id))
                {
                    DuelingRooms.Remove(obj.Id);
                }
                break;
            }
        }
Example #7
0
        public async Task UpdateRoom_WhenValidDetails_ShouldUpdateRoom(CreateProperty property, CreateRoom room, UpdateRoom updateRoom)
        {
            var propertyResponse = await CreateProperty(property);

            var response = await CreateRoom(propertyResponse.Property.Id, room);

            updateRoom.AccommodationType = response.Room.AccommodationType;
            updateRoom.NrOfOccupants     = response.Room.NrOfOccupants;

            var updateRoomResponse = await UpdateRoom(propertyResponse.Property.Id, response.Room.Id, updateRoom);

            Assert.AreEqual(HttpStatusCode.OK, updateRoomResponse.StatusCode);
            Assert.AreEqual(updateRoom.NrOfOccupants, updateRoomResponse.Room.NrOfOccupants);
            Assert.AreEqual(updateRoom.AccommodationType, updateRoomResponse.Room.AccommodationType);
        }
Example #8
0
        public async Task UpdateRoom_WhenNonExistingRoom_ReturnsNotFound(CreateProperty property, UpdateRoom room)
        {
            var propertyResponse = await CreateProperty(property);

            var response = await UpdateRoom(propertyResponse.Property.Id, 111111, room);

            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);;
        }
Example #9
0
        public async Task UpdateRoom_WhenNonExistingProperty_ReturnsNotFound(UpdateRoom room)
        {
            var response = await UpdateRoom(111111, 1, room);

            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
        }
Example #10
0
        public async Task <(Room Room, HttpStatusCode StatusCode)> UpdateRoom(int propertyId, int roomId, UpdateRoom room)
        {
            using (var content = new StringContent(JsonConvert.SerializeObject(room), Encoding.UTF8, "application/json"))
            {
                var response = await Client.PutAsync($"properties/{propertyId}/rooms/{roomId}", content);

                return(SerializationHelpers.GetEntityFromStream <Room>(await response.Content.ReadAsStreamAsync()), response.StatusCode);
            }
        }