public ListingsViewModel GetItemListingsViewModel(int itemId) { var httpWebRequest = (HttpWebRequest) WebRequest.Create(GW2ApiItemListings + itemId); httpWebRequest.Method = "GET"; var result = new ListingsViewModel(); var response = httpWebRequest.GetResponse(); using (var responseStream = response.GetResponseStream()) { var reader = new StreamReader(responseStream, Encoding.UTF8); result = JsonConvert.DeserializeObject<ListingsViewModel>(reader.ReadToEnd()); } return result; }
//ctor populates arrays for buy and sell charts public ListingChartViewModel(ListingsViewModel model) { ItemId = model.id; int modelBuysArrayLength = model.buys.Count; int modelSellsArrayLength = model.sells.Count; BuyListingsInts = new int[modelBuysArrayLength]; BuyPriceInts = new int[modelBuysArrayLength]; BuyQuantityInts = new int[modelBuysArrayLength]; SellListingInts = new int[modelSellsArrayLength]; SellPriceInts = new int[modelSellsArrayLength]; SellQuantityInts = new int[modelSellsArrayLength]; for (int i = 0; i<modelBuysArrayLength; i++) { BuyListingsInts[i] = model.buys[i].listings; BuyPriceInts[i] = model.buys[i].unit_price; BuyQuantityInts[i] = model.buys[i].quantity; } for (int i = 0; i < modelSellsArrayLength; i++) { SellListingInts[i] = model.sells[i].listings; SellPriceInts[i] = model.sells[i].unit_price; SellQuantityInts[i] = model.sells[i].quantity; } }