Example #1
0
 public Response()
 {
     League = new League();
     Leagues = new List<League>();
     Team = new Team();
     Teams = new List<Team>();
     Position = new Position();
     Positions = new List<Position>();
     Player = new Player();
     Players = new List<Player>();
 }
        private League PopulateLeagueInfoFromReader(SqlDataReader dr)
        {
            League league = new League();
            league.LeagueID = (int)dr["leagueID"];
            league.LeagueName = dr["leagueName"].ToString();

            return league;
        }
        public League GetTeamsByLeagueID(int leagueID)
        {
            League league = new League();
            Teams = new List<Team>();

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var cmd = new SqlCommand();
                cmd.CommandText = "GetTeamsByLeagueID";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Connection = cn;
                cmd.Parameters.AddWithValue("@LeagueID", leagueID);

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        league = PopulateLeagueInfoFromReader(dr);

                        Team team = new Team();
                        team.TeamID = (int)dr["TeamID"];
                        team.League.LeagueID = (int)dr["leagueID"];
                        team.League.LeagueName = dr["leagueName"].ToString();
                        team.Manager = dr["Manager"].ToString();
                        team.TeamName = dr["TeamName"].ToString();

                        Teams.Add(team);
                        league.Teams = Teams;
                    }
                }
            }

            return league;
        }
        public League GetLeagueByID(int leagueID)
        {
            var league = new League();

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand();

                cmd.CommandText = "GetLeagueByID";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = cn;
                cmd.Parameters.AddWithValue("@LeagueID", leagueID);

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        league = PopulateLeagueInfoFromReader(dr);
                    }
                }
            }

            return league;
        }
Example #5
0
 public Team()
 {
     League = new League();
     Players = new List<Player>();
 }