public static void Main(string[] args) { APIClient apiClient = new APIClient(); CityDataRepository LocationData = new CityDataRepository(); foreach (var items in LocationData.GetLocation()) { var CityAverageWeatherData = apiClient.GetLocation(items.ZipCode).Result; Console.WriteLine("__________________________________________"); Console.WriteLine(items.CityName + ", " + items.StateCode + "\t(" + items.ZipCode + ")\n"); Console.WriteLine("Date\t\tAvg. Temp (F)"); Console.WriteLine("------------------------------------------"); foreach (var data in CityAverageWeatherData) { Console.WriteLine("{0}{1}\t{2} F", data.Date.ToString("MM/dd/yyyy"), (data.RainCheck)?"*":"", ((1.8 * (data.AverageTemperature - 273)) + 32).ToString("0.00")); } Console.WriteLine("\n"); } Console.ReadKey(); }
public async void InitCity() { var idLogin = await BlobCache.LocalMachine.GetObject <string>("loginCookie"); string cityId = null; CitiesItem cityList = null; //Set the cookiee manually (propertie 'UseCookies = false') //Or use cookieContainer using (var client = new HttpClient(new HttpClientHandler { UseCookies = false })) { client.DefaultRequestHeaders.Add("Cookie", idLogin); var dashboardUrl = new Uri("http://app.casterstats.com/dashboard"); var resp = await client.GetAsync(dashboardUrl); string content = await resp.Content.ReadAsStringAsync(); List <Dashboard> dashboards = JsonConvert.DeserializeObject <List <Dashboard> >(content); foreach (var dashboard in dashboards) { cityId = dashboard.DashboardComponents.FirstOrDefault(x => x.Name.Equals("Cities")).Id; } if (cityId != null) { dashboardUrl = new Uri("http://app.casterstats.com/dashboard/component/userscity/" + cityId + ""); resp = await client.GetAsync(dashboardUrl); content = await resp.Content.ReadAsStringAsync(); cityList = JsonConvert.DeserializeObject <CitiesItem>(content); } } //Display the content SfDataGrid dataGrid = new SfDataGrid(); CityDataRepository cityData = new CityDataRepository(); if (cityList != null) { cityData.ListCity = cityList.CityDatas; dataGrid.AutoGenerateColumns = false; GridImageColumn countryIcon = new GridImageColumn(); countryIcon.MappingName = "Flag"; countryIcon.HeaderText = "Flag"; GridTextColumn countryName = new GridTextColumn(); countryName.MappingName = "Country"; countryName.HeaderText = "Country"; GridTextColumn nbUsers = new GridTextColumn(); nbUsers.MappingName = "Count"; nbUsers.HeaderText = "Users"; dataGrid.Columns.Add(countryIcon); dataGrid.Columns.Add(countryName); dataGrid.Columns.Add(nbUsers); dataGrid.ColumnSizer = ColumnSizer.Auto; dataGrid.ItemsSource = cityData.GetCityInfo(); dataGrid.AllowSorting = true; } Content = dataGrid; //page content = stacklayout }