public LocalTemperature GetTemperature(string zipCode) { var city = _geoLookupService.FindCity(zipCode); var state = _geoLookupService.FindState(zipCode); var coords = _geoLookupService.FindCoordinates(zipCode); var fahrenheitDegrees = _weatherService.GetTemperatureFahrenheit(coords.Latitude, coords.Longitude); var celciusDegrees = _temperatureConverter.ConvertFahrenheitToCelsius(fahrenheitDegrees); return(new LocalTemperature() { Fahrenheit = fahrenheitDegrees, Celsius = celciusDegrees, City = city, State = state, }); }
public static void Execute() { ConsoleExtension.WriteSeparator("Weather service example - before"); var zipCode = "83714"; var geoLookupService = new GeoLookupService(); var city = geoLookupService.FindCity(zipCode); var state = geoLookupService.FindState(zipCode); var coords = geoLookupService.FindCoordinates(zipCode); var weatherService = new WeatherService(); var fahrenheitDegrees = weatherService.GetTemperatureFahrenheit(coords.Latitude, coords.Longitude); var temperatureConverter = new TemperatureConverter(); var celciusDegrees = temperatureConverter.ConvertFahrenheitToCelsius(fahrenheitDegrees); Console.WriteLine( "The current temperature is {0}F/{1}C in {2}, {3}", fahrenheitDegrees.ToString("F1"), celciusDegrees.ToString("F1"), city, state); }