public Team GetTeam(int?id) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(F1Queries.GetTeam(id), connection); connection.Open(); try { using (SqlDataReader reader = command.ExecuteReader()) { Team t = new Team(); while (reader.Read()) { t.ID = (int)reader["id"]; t.Name = (string)reader["name"]; t.Chassis = (string)reader["chassis"]; t.Nationality = GetNationality((int)reader["nationality_id"]); t.TotalPodiums = (int)reader["totalpodiums"]; t.TotalWins = (int)reader["totalwins"]; t.TotalWCC = (int)reader["totalwcc"]; t.TotalPoints = (int)reader["totalpoints"]; t.Drivers = GetDriversFromTeam(t.ID); } return(t); } } catch (SqlException e) { throw e; } } }
public Driver GetDriver(int?id) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(F1Queries.GetDriver(id), connection); connection.Open(); try { using (SqlDataReader reader = command.ExecuteReader()) { Driver d = new Driver(); while (reader.Read()) { d.ID = (int)reader["id"]; d.DriverNumber = (int)reader["driverNumber"]; d.Name = (string)reader["name"]; d.SurName = (string)reader["surname"]; d.Nationality = GetNationality((int)reader["nationality_id"]); d.TotalStarts = (int)reader["totalstarts"]; d.TotalPodiums = (int)reader["totalpodiums"]; d.TotalWins = (int)reader["totalwins"]; d.TotalPolepositions = (int)reader["totalpolepositions"]; d.TotalWDC = (int)reader["totalwdc"]; d.TotalPoints = (int)reader["totalpoints"]; } return(d); } } catch (SqlException e) { throw e; } } }