예제 #1
0
        public IEnumerable <FullTradeOffer> ReceiveTradeOffers(
            bool getSentOffers,
            bool getReceivedOffers,
            string language      = "en_us",
            bool getDescriptions = true)
        {
            var offersResponse = this.TradeOfferWeb.GetActiveTradeOffers(
                getSentOffers,
                getReceivedOffers,
                getDescriptions,
                language);

            var fullOffersList = new List <FullTradeOffer>();

            if (offersResponse.AllOffers == null)
            {
                return(fullOffersList);
            }

            fullOffersList.AddRange(
                offersResponse.AllOffers.Select(
                    trade => new FullTradeOffer
            {
                Offer   = trade,
                MyItems = FullTradeItem.GetFullItemsList(
                    trade.ItemsToGive,
                    offersResponse.Descriptions),
                PartnerItems = FullTradeItem.GetFullItemsList(
                    trade.ItemsToReceive,
                    offersResponse.Descriptions)
            }));

            return(fullOffersList);
        }
예제 #2
0
        public void LoadCurrentTradeOffers(bool getSentOffers, bool getReceivedOffers, bool activeOnly, string language)
        {
            var tradesList = new List <FullTradeOffer>();

            var response = CurrentSession.SteamManager.TradeOfferWeb.GetTradeOffers(
                getSentOffers,
                getReceivedOffers,
                true,
                activeOnly,
                false,
                language: language);

            Program.LoadingForm.SetTotalItemsCount(
                response.AllOffers?.Count() ?? 0,
                response.AllOffers?.Count() ?? 0,
                "Total trades count");

            if (response.AllOffers == null)
            {
                this.currentTrades = tradesList;
                return;
            }

            foreach (var trade in response.AllOffers)
            {
                tradesList.Add(
                    new FullTradeOffer
                {
                    Offer          = trade,
                    ItemsToGive    = FullTradeItem.GetFullItemsList(trade.ItemsToGive, response.Descriptions),
                    ItemsToReceive = FullTradeItem.GetFullItemsList(trade.ItemsToReceive, response.Descriptions)
                });
                Program.LoadingForm.TrackLoadedIteration("{currentPage} of {totalPages} trades loaded");
            }

            this.currentTrades = tradesList;
        }