Exemple #1
0
        public static void Main(string[] args)
        {
            const string zipCode = "SeattleZipCode";

            // GeoLocService geoLookupService = new GeoLocService();

            // string city = geoLookupService.GetCityForZipCode(zipCode);
            // string state = geoLookupService.GetStateForZipCode(zipCode);
            // Coordinates coords = geoLookupService.GetCoordinatesForZipCode(zipCode);

            // WeatherService weatherService = new WeatherService();
            // double farenheit = weatherService.GetTempFarenheit(coords.Latitude, coords.Longitude);

            // MetricConverterService metricConverter = new MetricConverterService();
            // double celcius = metricConverter.FarenheitToCelcius(farenheit);


            ITemperatureService temperatureService = new TemperatureService();
            LocalTemperature    localTemp          = temperatureService.GetTemperature(zipCode);

            Console.WriteLine("The current temperature is {0}F/{1}C. in {2}, {3}",
                              localTemp.Farenheit.ToString("F1"),
                              localTemp.Celcius.ToString("F1"),
                              localTemp.City,
                              localTemp.State);

            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            const string zipCode = "83714";

            var temperatureFacade      = new TemperatureLookupFacade();
            LocalTemperature localTemp = temperatureFacade.GetTemperature(zipCode);

            Console.WriteLine("The current temperature is {0}F/{1}C. in {2}, {3}",
                              localTemp.Farenheit.ToString("F1"),
                              localTemp.Celcius.ToString("F1"),
                              localTemp.City,
                              localTemp.State);
        }
Exemple #3
0
        public ActionResult Get(string zipCode)
        {
            try
            {
                string           result            = string.Empty;
                var              temperatureFacade = new TemperatureLookupFacade();
                LocalTemperature localTemperature  = temperatureFacade.GetTemperature(zipCode);

                result = $"The current temperature is {localTemperature.Farenheit.ToString("F1")}F/{localTemperature.Celcius.ToString("F1")}C in {localTemperature.City}, {localTemperature.State}";

                return(Ok(result));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Exemple #4
0
        public LocalTemperature GetTemperature(string zipCode)
        {
            Coordinates coords = this.geoLocService.GetCoordinatesForZipCode(zipCode);
            string      city   = this.geoLocService.GetCityForZipCode(zipCode);
            string      state  = this.geoLocService.GetStateForZipCode(zipCode);

            double farenheit = this.weatherService.GetTempFarenheit(coords.Latitude, coords.Longitude);
            double celcius   = this.converter.FarenheitToCelcius(farenheit);

            LocalTemperature localTemperature = new LocalTemperature()
            {
                Farenheit = farenheit,
                Celcius   = celcius,
                City      = city,
                State     = state
            };

            return(localTemperature);
        }
        public LocalTemperature  GetTemperature(string zipCode)
        {
            var coords  = geoLookupService.GetCoordinates(zipCode);
            var city    = geoLookupService.GetCityForZipCode(zipCode);
            var country = geoLookupService.GetCountryForZipCode(zipCode);

            var farenheit = weatherService.GetTempFarenheit(coords.Latitude, coords.Longitude);
            var celcius   = converter.FarenheitToCelcius(farenheit);

            var localTemperature = new LocalTemperature()
            {
                Farenheit = farenheit,
                Celcius   = celcius,
                City      = city,
                Country   = country
            };

            return(localTemperature);
        }
Exemple #6
0
        public LocalTemperature GetTemperature(string zipCode)
        {
            var cords = geoLookUpService.GetCordsForZipCode(zipCode);
            var city  = geoLookUpService.GetCityForZipCode(zipCode);
            var state = geoLookUpService.GetStateForZipCode(zipCode);


            var farenheit = weatherService.GetTempFarenheit(cords.Latitude, cords.Longitude);
            var celsius   = englishMetricConverterService.FarenheitToCelsius(farenheit);

            var localTemperature = new LocalTemperature()
            {
                Farenheit = farenheit,
                Celsius   = celsius,
                City      = city,
                State     = state
            };

            return(localTemperature);
        }