public class Game { public string GameId { get; set; } [Required, Display(Name = "Game Name"), StringLength(200)] public string GameName { get; set; } [Required, Display(Name = "Recommended Age"), StringLength(25)] public string RecommendedAges { get; set; } [Required] public string Synopsis { get; set; } [StringLength(100)] public string Link { get; set; } [Required, Display(Name = "Time to Play"), StringLength(20)] public string Playtime { get; set; } public bool CheckedOut { get; set; } [Required, Display(Name = "Minimum Players")] public int MinPlayers { get; set; } [Required, Display(Name = "Maximum Players")] public int MaxPlayers { get; set; } [Required, Display(Name = "Minimum time to play")] public int MinPlaytime { get; set; } public int SearchType { get; set; } public int Num { get; set; } public int? Genre { get; set; } public string GenreName { get; set; } public string Email { get; set; } public DateTime DateCheckedOut { get; set; } public int? RowId { get; set; } public List ListGames() { using (SqlConnection oConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString)) { using (SqlCommand oCmd = new SqlCommand()) { try { oCmd.CommandText = "ListGames"; oCmd.CommandType = CommandType.StoredProcedure; oCmd.Connection = oConn; oConn.Open(); using (SqlDataReader reader = oCmd.ExecuteReader()) { List myList = new List(); while (reader.Read()) { Game game = new Game { GameId = reader[0].ToString(), GameName = reader[1].ToString(), RecommendedAges = reader[2].ToString(), Link = reader[3].ToString(), CheckedOut = (bool)reader[4], MinPlayers = (int)reader[5], MaxPlayers = (int)reader[6], Playtime = reader[7].ToString(), MinPlaytime = (int)reader[8], Synopsis = reader[9].ToString() }; myList.Add(game); } return myList; } } catch (Exception ex) { Errors.ErrorOccured(ex); return null; } finally { oCmd.Dispose(); oConn.Close(); } } } } }