Exemple #1
0
        public FixtureSummary(Fixture fixture)
        {
            this.FixtureID = fixture.FixtureID;
            this.HomeTeam = fixture.HomeTeam.ToString();
            this.AwayTeam = fixture.AwayTeam.ToString();

            if (fixture.Result != null)
            {
                this.HasResult = true;
                this.HomeScore = fixture.Result.HomeScore;
                this.AwayScore = fixture.Result.AwayScore;
            }
            else
            {
                this.HasResult = false;
            }
        }
        public ActionResult Generate(int id, int numberOfRounds, string submit)
        {
            if (submit == "Generate Fixtures")
            {
                if ((numberOfRounds % 2) != 0)
                {
                    return RedirectToAction("Generate", new { id = id });
                }

                using (TournamentEntities data = new TournamentEntities())
                {
                    Group group = data.Groups.SingleOrDefault(g => g.GroupID == id);

                    if (group != null)
                    {
                        // We add rounds 2 at a time, home and away
                        for (int round = 2; round <= numberOfRounds; round += 2)
                        {
                            foreach (Team team in group.Teams)
                            {
                                foreach (Team opponent in group.Teams)
                                {
                                    if (opponent.TeamID != team.TeamID)
                                    {
                                        Fixture fixture = new Fixture()
                                        {
                                            HomeTeamID = team.TeamID,
                                            AwayTeamID = opponent.TeamID,
                                        };

                                        data.Fixtures.AddObject(fixture);
                                    }
                                }
                            }
                        }

                        data.SaveChanges();
                    }
                }
            }

            return RedirectToAction("Index", new { id = id });
        }
 /// <summary>
 /// Create a new Fixture object.
 /// </summary>
 /// <param name="fixtureID">Initial value of the FixtureID property.</param>
 /// <param name="homeTeamID">Initial value of the HomeTeamID property.</param>
 /// <param name="awayTeamID">Initial value of the AwayTeamID property.</param>
 public static Fixture CreateFixture(global::System.Int32 fixtureID, global::System.Int32 homeTeamID, global::System.Int32 awayTeamID)
 {
     Fixture fixture = new Fixture();
     fixture.FixtureID = fixtureID;
     fixture.HomeTeamID = homeTeamID;
     fixture.AwayTeamID = awayTeamID;
     return fixture;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Fixtures EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFixtures(Fixture fixture)
 {
     base.AddObject("Fixtures", fixture);
 }