public async Task <ActionResult> GetWeatherForecastByCityName(string cityName) { if (cityName.IsNullTypeOrEmpty()) { return(BadRequest("You have to post a city name to get weather forecast results..")); } Stopwatch sw = Stopwatch.StartNew(); var location = LocationService.FetchLocationInfo(cityName); if (location != null) { var weatherForecast = ForecastService.FetchForecastInfo(location.CityId, location.Lat, location.Lon); if (weatherForecast != null) { weatherForecast.CityName = location.CityName; weatherForecast.LocationQueryElapsedMilliseconds = location.QueryElapsedMilliseconds; sw.Stop(); weatherForecast.MethodQueryElapsedMilliseconds = sw.ElapsedMilliseconds; } await _hubContext.Clients.All.SendAsync("LastForecastQuery", weatherForecast); return(Ok(weatherForecast)); } return(NotFound($"Could not find any records with city name:{cityName}")); }