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()); }
public static void UpdateWith(this Room room, UpdateRoomRequestModel model) { room.Number = model.Number; }
public async Task <IActionResult> UpdateRoom(UpdateRoomRequestModel updateRoomRequestModel) { await this.roomService.UpdateRoomAsync(updateRoomRequestModel); return(this.Ok($"Room number changed from <number> to {updateRoomRequestModel.Number}")); }