private async Task <IndexModel> BuildIndexModel(IndexModel model, GetAirportsRequest req) { var extResult = await _externalService.GetAirportsData(new[] { req.DepartureAirport, req.ArrivalAirport }); if (extResult.Length == 2) { var calcResult = _calculationService.CalculateGeoDistance(extResult[0].Location, extResult[1].Location); model.Fill(extResult[0], extResult[1], calcResult); model.GoogleMapsUrl = $"{_config.GoogleMapsDirectionsEmbedUrl}?origin={extResult[0].Location.LatLonFormatted}&destination={extResult[1].Location.LatLonFormatted}&mode=flying&key={_config.GoogleMapsApiKey}"; } else { model.Errors.Add("External service returned invalid result."); } return(model); }