public Dictionary <string, Tuple <RoomInfo, IRoom> > GetInfoForRoomsInBuilding(string buildingId) { // repo data var building = _buildingRepository.Get(buildingId); var floors = _floorRepository.GetAllByBuilding(buildingId).ToDictionary(_ => _.Id); var roomMetadatas = _roomRepository.GetRoomInfosForBuilding(buildingId).ToDictionary(_ => _.RoomAddress); // get these started in parallel while we load data from the repositories var roomTasks = roomMetadatas.ToDictionary(i => i.Key, i => _exchangeConferenceRoomDiscoveryService.GetRoomName(i.Key)).ToList(); // put it all together var results = new Dictionary <string, Tuple <RoomInfo, IRoom> >(); foreach (var kvp in roomTasks) { var roomAddress = kvp.Key; var room = kvp.Value.Result; if (null == room) { continue; } var roomMetadata = roomMetadatas.TryGetValue(roomAddress) ?? new RoomMetadataEntity(); var canControl = CanControl(roomMetadata); var floor = floors.TryGetValue(roomMetadata.FloorId) ?? new FloorEntity(); results.Add(roomAddress, new Tuple <RoomInfo, IRoom>(BuildRoomInfo(room, canControl, roomMetadata, building, floor), roomMetadata)); } return(results); }