Ejemplo n.º 1
0
        public void OnGet()
        {
            string            city   = "aalborg";
            OpenWeatherMapAPI owmAPI = new OpenWeatherMapAPI();

            WeatherIconSrc = owmAPI.GetIconUrl(city);
            Temperature    = owmAPI.GetCurrentTemperature(city);
            CategoryRepository cr = new CategoryRepository();

            Categories = cr.GetAllCategories();
            RideRepository rr = new RideRepository();

            AllRides = rr.GetAllRides();
        }
Ejemplo n.º 2
0
        public string GetLocalTemperature()                                // Retrieves the temperature for the City member in the class and returns it as a string
        {
            OpenWeatherMapAPI openWeatherMapAPI = new OpenWeatherMapAPI(); // Intitializing required variables
            double            temp = 0.0;

            try
            {
                temp = openWeatherMapAPI.GetCurrentTemperature(City); // Tries to run the code
            }
            catch (WebException)                                      //If the code can't run and the data isn't retrieved, a WebException is thrown and caught
            {
                return("N/A");                                        // The output string is set to placeholder text
            }
            return($"{temp}°C");                                      // If the code runs succesfully and the data is retrieved, the text is set to the temperature
        }
Ejemplo n.º 3
0
        public double GetTemperature(string city)
        {
            double temp = 0;

            try
            {
                temp = weatherAPI.GetCurrentTemperature(city);
            }
            catch (WebException)
            {
                return(-404);
            }

            return(temp);
        }