public WeatherBotBot(WeatherBotAccessors accessors, ILoggerFactory loggerFactory, WeatherDataSource weatherDataSource) { if (loggerFactory == null) { throw new System.ArgumentNullException(nameof(loggerFactory)); } _weatherDataSource = weatherDataSource; _logger = loggerFactory.CreateLogger <WeatherBotBot>(); _logger.LogTrace("Turn start."); _accessors = accessors ?? throw new System.ArgumentNullException(nameof(accessors)); }
public static string getWeatherData(string searchText, WeatherDataSource _weatherDataSource) { string responseCode = null; try { string locationKey = _weatherDataSource.GetLocationKey(searchText, out responseCode); WeatherData res = _weatherDataSource.GetWeatherData(locationKey, out responseCode); return("Time: " + res.LocalTime + ", Description: " + res.Description + ", temperature: " + res.TemperatureCelsius + " C"); } catch { if (responseCode != null) { return("oops, " + responseCode); } return("something went wrong"); } }