public async Task <CountryType> GetCountry([Parent] AirportType airport)
        {
            var country = (await _dataStore.FetchAllCountriesAsync()).FirstOrDefault(c => c.Name == airport.Country);

            return(country != null
                ? _mapper.Map <CountryType>(country)
                : new CountryType(airport.Country, null, null));
        }
        public async Task <IEnumerable <AirlineType> > GetAirlines([Parent] AirportType airport)
        {
            var routes = await GetRoutesInternal(airport);

            var airlineIds = routes.Select(r => r.AirlineId).Distinct();
            var airlines   = await Task.WhenAll(airlineIds.Select(_dataStore.GetAirlineByIdAsync));

            return(_mapper.Map <IEnumerable <AirlineType> >(airlines.Where(airline => airline != null)));
        }
        public async Task <IEnumerable <RouteType> > GetRoutes([Parent] AirportType airport)
        {
            var routes = await GetRoutesInternal(airport);

            return(_mapper.Map <IEnumerable <RouteType> >(routes));
        }
 private async Task <IEnumerable <Route> > GetRoutesInternal(AirportType airport)
 {
     return((await _dataStore.FetchRoutesByDestinationAirportAsync(airport.Id))
            .Concat(await _dataStore.FetchRoutesBySourceAirportAsync(airport.Id)));
 }