public static SteamPrice GetMarketPriceoverview(string currency, string appId, string market_hash_name) { Uri PriceOverviewUri; Uri.TryCreate("http://steamcommunity.com/market/priceoverview/?currency=" + currency + "&appid=" + appId + "&market_hash_name=" + market_hash_name, UriKind.Absolute, out PriceOverviewUri); System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); try { System.Net.Http.HttpResponseMessage response = client.GetAsync(PriceOverviewUri).Result; string priceString = response.Content.ReadAsStringAsync().Result; JsonObject priceJson; JsonObject.TryParse(priceString, out priceJson); // 3 for Euro as currency SteamPrice price = new SteamPrice(); if (priceJson.ContainsKey("success")) { if (priceJson.GetNamedBoolean("success")) { if (priceJson.ContainsKey("median_price")) { price.MarketMedianPrice = priceJson.GetNamedString("median_price"); } if (priceJson.ContainsKey("volume")) { price.MarketVolume = priceJson.GetNamedString("volume"); } if (priceJson.ContainsKey("lowest_price")) { price.MarketLowestPrice = priceJson.GetNamedString("lowest_price"); } price.DatePrice = DateTime.Now; } } return(price); } catch (Exception e) { return(null); } }
private void GetPriceButton_Click(object sender, RoutedEventArgs e) { //string s = DataReceiver.GetMarketPriceoverview("3", ((WeaponSkin)((Button)sender).DataContext).AppId, ((WeaponSkin)((Button)sender).DataContext).Market_hash_name); WeaponSkin skin = ((WeaponSkin)((Button)sender).DataContext); SteamPrice price = DataReceiver.GetMarketPriceoverview("3", skin.AppId, skin.Market_hash_name); //skin.PriceCol.Insert(0, DataReceiver.GetMarketPriceoverview("3", skin.AppId, skin.Market_hash_name)); foreach (WeaponSkin s in ViewModel.Inventory.SteamInventory) { if (s.Market_hash_name == skin.Market_hash_name) { if (s.PriceCol == null) { s.PriceCol = new ObservableCollection <Models.SteamInventory.SteamItem.SteamPrice>(); } s.PriceCol.Insert(0, price); } } }