public ActionResult Create(GameCreateModel gameModel, string tournamentSlug)
        {
            if (gameModel.HomeTeamId == gameModel.AwayTeamId)
            {
                ModelState.AddModelError("AwayTeamId", "A team cannot play itself");
            }
            if (ModelState.IsValid)
            {
                var game = new Game
                {
                    RoundId = gameModel.RoundId.Value,
                    GameTime = gameModel.GameTime
                };
                db.Games.Add(game);
                db.SaveChanges();

                var model = new GameEditModel
                {
                    Id = game.Id,
                    HomeTeamId = gameModel.HomeTeamId,
                    AwayTeamId = gameModel.AwayTeamId,
                    GameTime = gameModel.GameTime,
                    FieldId = gameModel.FieldId
                };
                return Edit(model, tournamentSlug);
            }

            var teams = db.Teams.Where(t => t.Tournament.Slug == tournamentSlug);
            ViewBag.HomeTeamId = new SelectList(teams, "Id", "Name");
            ViewBag.AwayTeamId = new SelectList(teams, "Id", "Name");

            ViewBag.RoundId = new SelectList(db.Rounds, "Id", "Name", gameModel.RoundId);
            return View(gameModel);
        }
        public ActionResult Create(Game game, string tournamentSlug)
        {
            if (ModelState.IsValid) {
                db.Games.Add(game);
                db.SaveChanges();
                return RedirectToAction("Standings", "Home", new { tournamentSlug });
            }

            ViewBag.RoundId = new SelectList(db.Rounds, "Id", "Id", game.RoundId);
            return View(game);
        }
        public ActionResult ReportScores(Game game, string tournamentSlug)
        {
            if (ModelState.IsValid)
            {
                db.Entry(game).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Standings", "Home", new {tournamentSlug});
            }

            return View(game);
        }
        public ActionResult ReportScores(Game game, string tournamentSlug)
        {
            if (ModelState.IsValid)
            {
                // Since we're only changing the score, we need to load the full
                // game from the database.
                var dbGame = db.Games.Include(g => g.Teams).FirstOrDefault(g => g.Id == game.Id);
                dbGame.HomeTeamScore = game.HomeTeamScore;
                dbGame.AwayTeamScore = game.AwayTeamScore;
                dbGame.HomeTeamCards = game.HomeTeamCards;
                dbGame.AwayTeamCards = game.AwayTeamCards;
                db.SaveChanges();
                return RedirectToAction("Standings", "Home", new {tournamentSlug});
            }

            return View(game);
        }