Exemplo n.º 1
0
        /// <summary>
        /// Returns the ItemPrices of the items with the given item IDs
        /// </summary>
        /// <param name="itemIds">The items to search for</param>
        /// <returns>Dictionary containing all item prices for the given items</returns>
        public IDictionary<int, ItemPrices> GetItemPrices(ICollection<int> itemIds)
        {
            Dictionary<int, ItemPrices> prices = new Dictionary<int, ItemPrices>();

            try
            {
                var listings = priceService.FindAll(itemIds);
                foreach (var listing in listings)
                {
                    if (listing.Value.ItemId > 0)
                    {
                        var listingPrices = new ItemPrices()
                        {
                            HighestBuyOrder = listing.Value.BuyOffers.UnitPrice,
                            BuyOrderQuantity = listing.Value.BuyOffers.Quantity,
                            LowestSellListing = listing.Value.SellOffers.UnitPrice,
                            SellOrderQuantity = listing.Value.SellOffers.Quantity
                        };
                        prices.Add(listing.Key, listingPrices);
                    }
                }
            }
            catch (GW2NET.Common.ServiceException ex)
            {
                // Don't crash, just return null
                logger.Warn("Error finding prices: {0}", ex);
            }

            return prices;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the ItemPrices of the item with the given item ID
        /// </summary>
        /// <param name="itemId">the item to retrieve the prices for</param>
        /// <returns>The prices for the item</returns>
        public ItemPrices GetItemPrices(int itemId)
        {
            ItemPrices itemPrices = null;
            try
            {
                var prices = priceService.Find(itemId);
                if (prices != null && prices.ItemId > 0)
                {
                    itemPrices = new ItemPrices()
                    {
                        HighestBuyOrder = prices.BuyOffers.UnitPrice,
                        BuyOrderQuantity = prices.BuyOffers.Quantity,
                        LowestSellListing = prices.SellOffers.UnitPrice,
                        SellOrderQuantity = prices.SellOffers.Quantity
                    };
                }
            }
            catch (GW2NET.Common.ServiceException ex)
            {
                // Don't crash, just return null
                logger.Warn("Error finding prices for itemId {0}: {1}", ex);
            }

            return itemPrices;
        }