Exemplo n.º 1
0
        public TeamSummary(Team team)
        {
            this.TeamName = team.ToString();
            this.TeamID = team.TeamID;

            CalculatePoints(team, team.HomeFixtures);
            CalculatePoints(team, team.AwayFixtures);
        }
Exemplo n.º 2
0
        private void CalculatePoints(Team team, IEnumerable<Fixture> fixtures)
        {
            foreach (Fixture fixture in fixtures)
            {
                if (fixture.Result != null)
                {
                    this.GamesPlayed++;

                    if (fixture.HomeTeamID == team.TeamID)
                    {
                        // Home
                        this.GoalsFor = this.GoalsFor + fixture.Result.HomeScore;
                        this.GoalsAgainst = this.GoalsAgainst + fixture.Result.AwayScore;

                        if (fixture.Result.HomeScore > fixture.Result.AwayScore)
                        {
                            // win
                            this.GamesWon++;
                            this.Points = this.Points + 3;
                        }
                        else if (fixture.Result.HomeScore < fixture.Result.AwayScore)
                        {
                            this.GamesLost++;
                        }
                        else
                        {
                            this.GamesDrawn++;
                            this.Points = this.Points + 1;
                        }
                    }
                    else
                    {
                        // Away
                        this.GoalsFor = this.GoalsFor + fixture.Result.AwayScore;
                        this.GoalsAgainst = this.GoalsAgainst + fixture.Result.HomeScore;

                        if (fixture.Result.AwayScore > fixture.Result.HomeScore)
                        {
                            // win
                            this.GamesWon++;
                            this.Points = this.Points + 3;
                        }
                        else if (fixture.Result.AwayScore < fixture.Result.HomeScore)
                        {
                            // loss
                            this.GamesLost++;
                        }
                        else
                        {
                            this.GamesDrawn++;
                            this.Points = this.Points + 1;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult Add(Team team)
        {
            using (TournamentEntities data = new TournamentEntities())
            {
                Group group = data.Groups.SingleOrDefault(g => g.GroupID == team.GroupID);

                if (group != null)
                {
                    data.Teams.AddObject(team);
                    data.SaveChanges();
                }
            }

            return RedirectToAction("Index", "Group", new { id = team.GroupID });
        }
Exemplo n.º 4
0
        public ActionResult Edit(int id, Team postedTeam)
        {
            using (TournamentEntities data = new TournamentEntities())
            {
                Team team = data.Teams.SingleOrDefault(t => t.TeamID == id);

                if (team != null)
                {
                    UpdateModel<Team>(team);

                    data.SaveChanges();
                }
            }

            return RedirectToAction("Index", new { id = id });
        }
Exemplo n.º 5
0
        public TeamDetails(Team team)
        {
            this.TeamID = team.TeamID;
            this.TeamName = team.Name;
            this.Player = team.Player;
            this.GroupID = team.GroupID;
            this.GroupName = team.Group.Name;
            this.TournamentID = team.Group.TournamentID;
            this.TournamentName = team.Group.Tournament.Name;

            List<FixtureSummary> awayFixtures = new List<FixtureSummary>();

            foreach (Fixture fixture in team.AwayFixtures)
            {
                awayFixtures.Add(new FixtureSummary(fixture));
            }

            this.AwayFixtures = awayFixtures;

            List<FixtureSummary> homeFixtures = new List<FixtureSummary>();

            foreach (Fixture fixture in team.HomeFixtures)
            {
                homeFixtures.Add(new FixtureSummary(fixture));
            }

            this.HomeFixtures = homeFixtures;

            this.OtherTeams = new Dictionary<int, string>();

            foreach (Team otherTeam in team.Group.Teams.OrderBy(t => t.Name))
            {
                if (otherTeam.TeamID != team.TeamID)
                {
                    this.OtherTeams.Add(otherTeam.TeamID, otherTeam.ToString());
                }
            }
        }
 /// <summary>
 /// Create a new Team object.
 /// </summary>
 /// <param name="teamID">Initial value of the TeamID property.</param>
 /// <param name="groupID">Initial value of the GroupID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="player">Initial value of the Player property.</param>
 public static Team CreateTeam(global::System.Int32 teamID, global::System.Int32 groupID, global::System.String name, global::System.String player)
 {
     Team team = new Team();
     team.TeamID = teamID;
     team.GroupID = groupID;
     team.Name = name;
     team.Player = player;
     return team;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Teams EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTeams(Team team)
 {
     base.AddObject("Teams", team);
 }