public void ConnectExistingFlightsToStations(IEnumerable <FlightHistory> flights) { WasInitialized = true; foreach (FlightHistory fh in flights) { IStationService stationService = stationServices.FirstOrDefault(ss => ss.Station.Id == fh.StationId); if (stationService is null) { logger.LogError($"Flight {fh.FlightId} is connected to a non existing station!"); throw new KeyNotFoundException("Invlid Flight!"); } ILogger <IFlightService> flLogger = loggerFactory.CreateLogger <IFlightService>(); IFlightService flightService = new FlightService(fh.Flight, flLogger); stationService.FlightArrived(flightService); } }