static void climaRealtime() { Out output = new Out(); ClimaWeatherController climaWeatherController = new ClimaWeatherController(); output.outputToConsole("***** ClimaWeather Weather *****"); string cityName = "Valletta"; ClimaRealTimeModel crtm = climaWeatherController.getWeather(cityName, EndpointType.CURRENT); output.outputToConsole($"In {cityName} current temp is: {crtm.temp.value}"); }
public ClimaRealTimeModel getWeather(string cityName, EndpointType endpointType) { AccuWeatherLocationModel awlm = awc.getPosition(cityName); //Console.WriteLine(awlm.GeoPosition.Latitude); //List<AccuWeatherForecast> forecastList = new List<AccuWeatherForecast>(); restClient.endpoint = climaCellEndpoint.getByCityNameEndpoint(awlm.GeoPosition.Longitude, awlm.GeoPosition.Latitude, endpointType); string response = restClient.makeRequest(); JSONParser <ClimaRealTimeModel> jsonParser = new JSONParser <ClimaRealTimeModel>(); ClimaRealTimeModel deserialisedClimaModel = new ClimaRealTimeModel(); deserialisedClimaModel = jsonParser.parseJSON(response, Parser.Version.NETCore2); //foreach (DailyForecast dailyForecast in deserialisedAccuWeatherModel.DailyForecasts) //{ // forecastList.Add(new AccuWeatherForecast(dailyForecast.EpochDate, dailyForecast.Temperature.Minimum.Value, dailyForecast.Temperature.Maximum.Value)); //} return(deserialisedClimaModel); }