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); }
public ActionResult Create(Team team) { if (ModelState.IsValid) { db.Teams.Add(team); db.SaveChanges(); return RedirectToAction("Index"); } return View(team); }
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); }
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); }
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); }
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; }
public bool InGame(Team team) { return team.Id == HomeTeam.Id || team.Id == AwayTeam.Id; }