private string GenerateCsvContent(ResponseOpenWeather obResponse) { string sDelimiter = Settings.Default.FieldDelimiter; StringBuilder sbContent = new StringBuilder(); //Add headers string sHeaders = "Temperature" + sDelimiter + "Units" + sDelimiter + "Precipitation"; sbContent.AppendLine(sHeaders); //Add Temperature sbContent.Append(obResponse.Main.Temp); sbContent.Append(sDelimiter); //Add Units sbContent.Append("C"); sbContent.Append(sDelimiter); //Add Precipitation indicator if (obResponse.Weather.Any(w => w.Main.Equals("Rain"))) { sbContent.AppendLine("true"); } else { sbContent.AppendLine("false"); } return(sbContent.ToString()); }
private ResponseOpenWeather GetWeather() { OpenWeatherCaller obCaller = new OpenWeatherCaller(); ResponseOpenWeather obResult = obCaller.GetWeather(); obCaller = null; return(obResult); }
public ResponseOpenWeather GetWeather() { ResponseOpenWeather obResponse = null; try { var client = new RestClient(_uri); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); obResponse = JsonConvert.DeserializeObject <ResponseOpenWeather>(response.Content); } catch { obResponse = null; } return(obResponse); }