public List<Game> AllWantedGames()
{
//return all games that are wanted
if (!connectionopen)
{
DBConnector.Open();
connectionopen = true;
}
FbTransaction DBTransaction = DBConnector.BeginTransaction();
FbCommand DBCommand = new FbCommand("SELECT * FROM games WHERE wanted = '1'", DBConnector, DBTransaction);
FbDataReader DBReader = DBCommand.ExecuteReader();
List<Game> Result = new List<Game>();
while (DBReader.Read())
{
Game SingleResult = new Game();
SingleResult.Name = DBReader.GetString(1);
SingleResult.ID = DBReader.GetInt32(0);
SingleResult.InfoXML = new XmlDocument();
SingleResult.InfoXML.LoadXml(DBReader.GetString(2));
SingleResult.ReleaseDate = DateTime.Parse(DBReader.GetString(6));
SingleResult.InstallPath = DBReader.GetString(7);
SingleResult.scraper_gdb_id = DBReader.GetInt32(8);
SingleResult.Platform = DBReader.GetString(9);
if (DBReader.GetInt32(3) != 0)
SingleResult.Downloaded = true;
else
SingleResult.Downloaded = false;
if (DBReader.GetInt32(4) != 0)
SingleResult.Snatched = true;
else
SingleResult.Snatched = false;
if (DBReader.GetInt32(5) != 0)
SingleResult.Wanted = true;
else
SingleResult.Wanted = false;
Result.Add(SingleResult);
}
//If there aren't any results: Just return null.
if (Result.Count == 0)
{
DBConnector.Close();
connectionopen = false;
return null;
}
DBConnector.Close();
connectionopen = false;
return Result;
}