Exemple #1
0
        public ActionResult GetTeam(int teamId)
        {
            var data = new Object { };
            Team team = new Team(teamId);

            data = new { success = true, team = team };

            return Json(data);
        }
Exemple #2
0
        public List<Team> AllTeams(int leagueId)
        {
            List<Team> teams = new List<Team>();

            string queryString = "SELECT * FROM [dbo].[Teams] WHERE leagueId = @leagueId Order By City";
            using (SqlConnection connection = new SqlConnection(Base.conn))
            {
                // Create the Command and Parameter objects.
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.AddWithValue("leagueId", leagueId);
                try
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        Team team = new Team();
                        team.TeamId = reader.GetInt32(0);
                        team.LeagueId = reader.GetInt32(1);
                        team.League = reader.GetString(2);
                        team.ConferenceId = reader.GetInt32(3);
                        team.Conference = reader.GetString(4);
                        team.Name = reader.GetString(5);
                        team.City = reader.GetString(6);
                        team.ScrapId = reader.GetString(7);
                        team.ScrapUrl = reader.GetString(8);
                        team.Scrap2Url = reader.GetString(9);
                        teams.Add(team);
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    SportsError sError = new SportsError(ex, leagueId);
                }
            }

            return teams;
        }