public void NotifyFlightChanges(FlightEventArgs e) { if (e is null) { throw new ArgumentNullException(nameof(e), "The event args are required"); } Flight flight = e.Flight; FlightDTO flightDto = FlightDTO.FromDBModel(flight); StationDTO fromDto = null, toDto = null; Station from = e.StationFrom; if (from is not null) { fromDto = StationDTO.FromDBModel(from); } Station to = e.StationTo; if (to is not null) { toDto = StationDTO.FromDBModel(to); } hubContext.Clients.Group($"CT-{e.Flight.ControlTower.Name}").SendAsync("FlightMoved", flightDto, fromDto, toDto); }
public AirportDataDTO GetAirportData(string name) { ControlTower controlTower = stationTreeBuilder[name]?.ControlTower ?? throw new KeyNotFoundException("No control tower with given name found!"); IEnumerable <FlightDTO> flights = GetFlightDtos(controlTower.Id); IEnumerable <StationDTO> stations = controlTower.Stations.Select(s => StationDTO.FromDBModel(s)); IEnumerable <StationRelationDTO> stationRelations = GetStationRelationDtos(controlTower.Stations); IEnumerable <StationControlTowerRelationDTO> firstStations = controlTower.FirstStations .Select(sctr => StationControlTowerRelationDTO.FromDBModel(sctr)); ControlTowerDTO controlTowerDTO = ControlTowerDTO.FromDBModel(controlTower); logger.LogInformation("Successfully built airport data."); return(new AirportDataDTO { ControlTower = controlTowerDTO, FirstStations = firstStations, Flights = flights, StationRelations = stationRelations, Stations = stations }); }