public ActionResult Schedule(SelectionViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.GameSelectionTitle = "Schedule Game - Details";
                ViewBag.GameSelectionButton = "Schedule";
                ViewBag.ReturnTo = Url.Action("Select", "Game", new {vm.Activity, vm.Size, vm.Date, vm.SlotId });
                ViewBag.CancelUrl = Url.Action("Slot", "Game", new { vm.Activity, vm.Size, vm.Date });

                return View(vm);
            }

            GameCreationResult result = new GameCreator(Context, Server.MapPath("/bin")).Create(vm.SlotId,
                                                                        vm.Team1Id,
                                                                        vm.Team2Id,
                                                                        MapActivity(vm.Activity),
                                                                        vm.Notes,
                                                                        vm.AreRefereesNeeded,
                                                                        LoggedInUser);

            if (result == GameCreationResult.SlotNotAvailable)
            {
                TempData["message"] = "That slot is no longer available.";
                return RedirectToAction("Slot", "Game", new { vm.Activity, vm.Size, vm.Date });
            }

            TempData["message"] = "Game scheduled!";
            return RedirectToAction("Slot", "Game", new { vm.Activity, vm.Size, vm.Date });
        }
        public ActionResult Edit(SelectionViewModel vm)
        {
            Game game = Context.Games.Include("Slot").SingleOrDefault(g => g.Id == vm.Id && g.ScheduledBy.Id == LoggedInUser.Id);

            if (game == null)
            {
                TempData["message"] = "Game cannot be found for your user account.";
                return RedirectToAction("Summary");
            }

            if (!ModelState.IsValid)
            {
                ViewBag.GameSelectionTitle = "Game Edit";
                ViewBag.GameSelectionButton = "Update";
                ViewBag.ReturnTo = Url.Action("Edit", "Game", new { vm.Id });
                ViewBag.CancelUrl = Url.Action("Summary");

                return View("Select", vm);
            }

            Team team1 = Context.ExternalTeams.SingleOrDefault(t => t.Id == vm.Team1Id) ??
                         (Team) Context.ClubTeams.SingleOrDefault(t => t.Id == vm.Team1Id);

            Team team2 = Context.ExternalTeams.SingleOrDefault(t => t.Id == vm.Team2Id) ??
                         (Team) Context.ClubTeams.SingleOrDefault(t => t.Id == vm.Team2Id);

            if (team1 == null || team2 == null)
            {
                TempData["message"] = "One of the teams cannot be found.";
                return RedirectToAction("Summary");
            }

            game.Team1 = team1;
            game.Team2 = team2;
            game.Notes = vm.Notes;

            Context.SaveChanges();

            new RefereeEmailer(Context, Server.MapPath("~/bin")).EmailModified(game);

            return RedirectToAction("Summary");
        }