public IEnumerable <ProductInShelf> GetProductsInShelf(Shelf shelf) { SQLiteConnection connection = GetConnectionForTable("azusa.products"); SQLiteCommand cmd = connection.CreateCommand(); cmd.CommandText = Resources.GetProductsInShelf_Postgre; cmd.Parameters.Add("@shelf", DbType.Int32); cmd.Parameters["@shelf"].Value = shelf.Id; SQLiteDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { ProductInShelf product = new ProductInShelf(); product.Id = dataReader.GetInt32(0); product.Name = dataReader.GetString(1); if (!dataReader.IsDBNull(2)) { product.Price = dataReader.GetDouble(2); } if (!dataReader.IsDBNull(3)) { product.BoughtOn = dataReader.GetDateTime(3); } if (!dataReader.IsDBNull(4)) { product.ScreenshotSize = dataReader.GetInt64(4); } if (!dataReader.IsDBNull(5)) { product.CoverSize = dataReader.GetInt64(5); } if (!dataReader.IsDBNull(6)) { product.NSFW = dataReader.GetBoolean(6); } if (dataReader.IsDBNull(7)) { Debug.WriteLine(product.Name + " has no media!"); continue; } product.IconId = Convert.ToInt32(dataReader.GetInt64(7)); product.NumberOfDiscs = dataReader.GetInt32(8); product.ContainsUndumped = dataReader.GetInt32(9) > 0; product.MissingGraphData = dataReader.GetInt32(10); yield return(product); } dataReader.Dispose(); cmd.Dispose(); }
public IEnumerable <ProductInShelf> GetProductsInShelf(Shelf shelf) { string rawJson = webClient.DownloadString(String.Format("/azusa/products/inshelf/{0}", shelf.Id)); JArray deserializeObject = (JArray)JsonConvert.DeserializeObject(rawJson); foreach (JToken jToken in deserializeObject) { ProductInShelf productInShelf = new ProductInShelf(); productInShelf.CoverSize = jToken.Value <long>("CoverSize"); productInShelf.BoughtOn = UnixTimeConverter.FromUnixTime(jToken.Value <long>("BoughtOn")); productInShelf.ContainsUndumped = jToken.Value <bool>("ContainsUndumped"); productInShelf.IconId = jToken.Value <int>("IconId"); productInShelf.Id = jToken.Value <int>("Id"); productInShelf.MissingGraphData = jToken.Value <int>("MissingGraphData"); productInShelf.NSFW = jToken.Value <bool>("NSFW"); productInShelf.Name = jToken.Value <string>("Name"); productInShelf.NumberOfDiscs = jToken.Value <int>("NumberOfDiscs"); productInShelf.Price = jToken.Value <double>("Price"); productInShelf.relatedShelf = shelf; yield return(productInShelf); } yield break; }