Ejemplo n.º 1
0
 public ActionResult Edit(Team team, string tournamentSlug)
 {
     if (ModelState.IsValid) {
         db.Entry(team).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Standings", "Home", new { id = tournamentSlug });
     }
     return View(team);
 }
Ejemplo n.º 2
0
        public ActionResult Create(Team team)
        {
            if (ModelState.IsValid) {
                db.Teams.Add(team);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(team);
        }
Ejemplo n.º 3
0
        public ActionResult Create(Team team, string tournamentSlug)
        {
            if (ModelState.IsValid)
            {
                var tournament = db.Tournaments.First(t => t.Slug == tournamentSlug);
                team.Tournament = tournament;
                db.Teams.Add(team);
                db.SaveChanges();
                return RedirectToAction("Standings", "Home", new {tournamentSlug});
            }

            return View(team);
        }
Ejemplo n.º 4
0
        public void WinCountsAsThreePoints()
        {
            // arrange
            var homeTeam = new Team();
            var awayTeam = new Team();
            var games = new List<Game> {
                new Game {
                    Teams = new List<Team> { homeTeam, awayTeam },
                    HomeTeamScore = 2,
                    AwayTeamScore = 1
                }
            };
            homeTeam.Games = games;

            // act
            int points = homeTeam.Points;

            // assert
            Assert.Equal(3, points);
        }
Ejemplo n.º 5
0
        public void LossCountsAsZeroPoints()
        {
            // arrange
            var homeTeam = new Team();
            var awayTeam = new Team();
            var games = new List<Game> {
                new Game {
                    Teams = new List<Team> { homeTeam, awayTeam },
                    HomeTeamScore = 1,
                    AwayTeamScore = 2
                }
            };
            homeTeam.Games = games;

            // act
            int points = homeTeam.Points;

            // assert
            Assert.Equal(0, points);
        }
Ejemplo n.º 6
0
 public void AddTeams(Team homeTeam, Team awayTeam)
 {
     if (Teams == null) return;
     Teams.Clear();
     Teams.Add(homeTeam);
     HomeTeamId = homeTeam.Id;
     Teams.Add(awayTeam);
     AwayTeamId = awayTeam.Id;
 }
Ejemplo n.º 7
0
 public bool InGame(Team team)
 {
     return team.Id == HomeTeam.Id || team.Id == AwayTeam.Id;
 }