Пример #1
0
        private static ItemHistoryRecord ReadItemHistoryRecord(dynamic item)
        {
            AppId.AppName?appId = null;
            if (item.app_id != null)
            {
                appId = (AppId.AppName)(int) item.app_id;
            }
            string   itemId         = item.item_id ?? null;
            string   marketHashName = item.market_hash_name ?? null;
            double?  price          = item.price ?? null;
            DateTime?lastUpdateAt   = null;

            if (item.last_update_at != null)
            {
                lastUpdateAt = DateTimeExtension.FromUnixTime((long)item.last_update_at);
            }
            DateTime?listedAt = null;

            if (item.listed_at != null)
            {
                listedAt = DateTimeExtension.FromUnixTime((long)item.listed_at);
            }
            DateTime?withdrawnAt = null;

            if (item.withdrawn_at != null)
            {
                withdrawnAt = DateTimeExtension.FromUnixTime((long)item.withdrawn_at);
            }
            bool?listedByMe = item.listed_by_me ?? null;
            bool?onHold     = item.on_hold ?? null;
            bool?onSale     = item.on_sale ?? null;
            ItemHistoryRecordType recordType = (item.bought_at != null) ? ItemHistoryRecordType.BoughtAt : ItemHistoryRecordType.SoldAt;
            DateTime?recordTime;

            if (recordType == ItemHistoryRecordType.BoughtAt)
            {
                recordTime = DateTimeExtension.FromUnixTime((long)item.bought_at);
            }
            else
            {
                if (item.sold_at != null)
                {
                    recordTime = DateTimeExtension.FromUnixTime((long)item.sold_at);
                }
                else
                {
                    recordTime = null;
                }
            }

            ItemHistoryRecord itemHistoryRecord = new ItemHistoryRecord(appId, itemId, marketHashName, price,
                                                                        recordType, lastUpdateAt, listedAt, withdrawnAt, listedByMe, onHold, onSale, recordTime);

            return(itemHistoryRecord);
        }
Пример #2
0
        private static List <ItemHistoryRecord> ReadItemHistoryRecords(string result)
        {
            dynamic responseServerD = JsonConvert.DeserializeObject(result);
            dynamic itemsD          = responseServerD.data.items;

            List <ItemHistoryRecord> itemHistoryRecords = new List <ItemHistoryRecord>();

            if (itemsD != null)
            {
                foreach (dynamic item in itemsD)
                {
                    ItemHistoryRecord itemHistoryRecord = ReadItemHistoryRecord(item);
                    itemHistoryRecords.Add(itemHistoryRecord);
                }
            }

            return(itemHistoryRecords);
        }