Exemple #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();
        }
Exemple #2
0
        public string GetIconUrl()                                         // Retrieves a url for an icon for the City member in the class and returns it as a string
        {
            OpenWeatherMapAPI openWeatherMapAPI = new OpenWeatherMapAPI(); // Initializing required variables
            string            iconUrl           = "";

            try
            {
                iconUrl = openWeatherMapAPI.GetIconUrl(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(@"\img\placeholder.png");              // A URL for a placeholder image is returned instead of the intended URL
            }
            return(iconUrl);                                  // If the code runs succesfully and the data is retrieved, the URL is returned
        }