public WeatherVM() { if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { SelectedCity = new City { LocalizedName = "New York" }; CurrrentConditions = new CurrrentConditions { WeatherText = "Partly cloudy", HasPrecipitation = true, Temperature = new Temperature { Metric = new Units { Value = "21" } } }; } SearchCommand = new SearchCommand(this); Cities = new ObservableCollection <City>(); }
public static async Task <CurrrentConditions> GetCurrrentConditions(string cityKey) { CurrrentConditions currrentConditions = new CurrrentConditions(); string url = BASE_URL + string.Format(CURRENT_CONDITIONS_ENDPOINT, cityKey, API_KEY); using (HttpClient client = new HttpClient()) { var response = await client.GetAsync(url); string json = await response.Content.ReadAsStringAsync(); currrentConditions = (JsonConvert.DeserializeObject <List <CurrrentConditions> >(json)).FirstOrDefault(); } return(currrentConditions); }