//Call IPService //Call GeoService with _ipaddress.IP //Call NWSEndpointService with _usergeo.latitude.ToString(), _usergeo.longitude.ToString(); //Call ForecastService with _nwsemodel.Properties.forecast public async Task <ForecastModel> GetWeatherAsync() { ForecastModel _forecast = new ForecastModel(); ForecastService _forecastservice = new ForecastService(); NWSEndpointModel _nwsemodel = new NWSEndpointModel(); NWSEndpointService _nwseservice = new NWSEndpointService(); IPAddressModel _ipaddress = new IPAddressModel(); IPService _ipservice = new IPService(); UserGeolocationModel _usergeo = new UserGeolocationModel(); GeoService _geoservice = new GeoService(); //Call IPService //Call GeoService with _ipaddress.IP //Call NWSEndpointService with _usergeo.latitude.ToString(), _usergeo.longitude.ToString(); //Call ForecastService with _nwsemodel.Properties.forecast _ipaddress = await _ipservice.GetIPAsync(); _usergeo = await _geoservice.GetLocationAsync(_ipaddress.IP); _nwsemodel = await _nwseservice.GetAPIEndpointAsync(_usergeo.latitude.ToString(), _usergeo.longitude.ToString()); _forecast = await _forecastservice.GetForecastAsync(_nwsemodel.properties.forecast); return(_forecast); }
public async Task <NWSEndpointModel> GetAPIEndpointAsync(string latitude, string longitude) { string APIEndpoint = "https://api.weather.gov/points/" + latitude.Substring(0, latitude.IndexOf(".") + 5) + "," + longitude.Substring(0, latitude.IndexOf(".") + 5); var client = new RestClient(APIEndpoint); client.Timeout = -1; var request = new RestRequest(Method.GET); client.UserAgent = "*****@*****.**"; IRestResponse response = await client.ExecuteAsync(request); NWSEndpointModel _nwsemodel = new NWSEndpointModel(); return(JsonConvert.DeserializeObject <NWSEndpointModel>(response.Content)); }