Ejemplo n.º 1
0
        public void SortBadges(string method)
        {
            lblDrops.Text = "Sorting results based on your settings, please wait...";
            switch (method)
            {
            case "mostcards":
                AllBadges = AllBadges.OrderByDescending(b => b.RemainingCard).ToList();
                break;

            case "leastcards":
                AllBadges = AllBadges.OrderBy(b => b.RemainingCard).ToList();
                break;

            case "mostvalue":
                var query = string.Format("http://api.enhancedsteam.com/market_data/average_card_prices/im.php?appids={0}",
                                          string.Join(",", AllBadges.Select(b => b.AppId)));
                var json          = new WebClient().DownloadString(query);
                var convertedJson = JsonConvert.DeserializeObject <EnhancedsteamHelper>(json);
                foreach (var price in convertedJson.Avg_Values)
                {
                    var badge = AllBadges.SingleOrDefault(b => b.AppId == price.AppId);
                    if (badge != null)
                    {
                        badge.AveragePrice = price.Avg_Price;
                    }
                }
                AllBadges = AllBadges.OrderByDescending(b => b.AveragePrice).ToList();
                break;

            default:
                return;
            }
        }
Ejemplo n.º 2
0
        private void _FillAveragePrice()
        {
            if (!AllBadges.Any() || AllBadges.First().AveragePrice != 0)
            {
                return;
            }

            var query = string.Format("http://api.enhancedsteam.com/market_data/average_card_prices/im.php?appids={0}",
                                      string.Join(",", AllBadges.Select(b => b.AppId)));
            var json = new WebClient()
            {
                Encoding = Encoding.UTF8
            }.DownloadString(query);
            var convertedJson = JsonConvert.DeserializeObject <EnhancedsteamHelper>(json);

            foreach (var price in convertedJson.Avg_Values)
            {
                var badge = AllBadges.SingleOrDefault(b => b.AppId == price.AppId);
                if (badge != null)
                {
                    badge.AveragePrice = price.Avg_Price;
                }
            }
        }