コード例 #1
0
        public async Task <IActionResult> Put(int id, UpdateRoomRequestModel model)
        {
            var room = await this.context.Rooms.FindAsync(id);

            if (room == null)
            {
                return(this.NotFound());
            }

            room.UpdateWith(model);

            this.context.Rooms.Update(room);
            await this.context.SaveChangesAsync();

            return(this.NoContent());
        }
コード例 #2
0
 public static void UpdateWith(this Room room, UpdateRoomRequestModel model)
 {
     room.Number = model.Number;
 }
コード例 #3
0
        public async Task <IActionResult> UpdateRoom(UpdateRoomRequestModel updateRoomRequestModel)
        {
            await this.roomService.UpdateRoomAsync(updateRoomRequestModel);

            return(this.Ok($"Room number changed from <number> to {updateRoomRequestModel.Number}"));
        }