public ActionResult Create(FixtureViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.Validate();

                    // TODO Ideally a service should do this
                    model.Fixture = model.MapToFixture(
                        model.Fixture,
                        this.competitionService.GetTeamLeagueByTeamIdInCurrentSeason(model.HomeTeamId),
                        this.competitionService.GetTeamLeagueByTeamIdInCurrentSeason(model.AwayTeamId),
                        model.Referee1Id.HasValue ? this.refereeService.Get(model.Referee1Id.Value) : null,
                        model.Referee2Id.HasValue ? this.refereeService.Get(model.Referee2Id.Value) : null,
                        this.membershipService.GetLoggedInUser(),
                        model.OneOffVenueId.HasValue ? oneOffVenueService.Get(model.OneOffVenueId.Value) : null);

                    if (model.Fixture.IsCupFixture)
                    {
                        model.Fixture.Cup = cupService.Get(model.LeagueOrCupId);
                    }

                    fixtureService.Save(model.Fixture);
                    fixtureService.Commit();

                    SuccessMessage(FormMessages.SaveSuccess);

                    if (model.CreateAnotherFixture)
                    {
                        return(RedirectToAction("Create", new { leagueOrCupId = model.LeagueOrCupId, isCup = model.Fixture.IsCupFixture }));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (FixtureTeamsTheSameException)
            {
                ErrorMessage(FormMessages.FixtureTeamsTheSame);
            }

            PopulateStaticData(model);

            return(View(model));
        }
        public ActionResult Edit(FixtureViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.Validate();

                    Fixture fixtureToUpdate = fixtureService.Get(model.Fixture.Id);
                    TryUpdateModel(fixtureToUpdate, "Fixture");

                    fixtureToUpdate = model.MapToFixture(
                        fixtureToUpdate,
                        this.competitionService.GetTeamLeagueByTeamIdInCurrentSeason(model.HomeTeamId),
                        this.competitionService.GetTeamLeagueByTeamIdInCurrentSeason(model.AwayTeamId),
                        model.Referee1Id.HasValue ? this.refereeService.Get(model.Referee1Id.Value) : null,
                        model.Referee2Id.HasValue ? this.refereeService.Get(model.Referee2Id.Value) : null,
                        this.membershipService.GetLoggedInUser(),
                        model.OneOffVenueId.HasValue ? oneOffVenueService.Get(model.OneOffVenueId.Value) : null);

                    fixtureService.Save(fixtureToUpdate);
                    fixtureService.Commit();

                    SuccessMessage(FormMessages.SaveSuccess);

                    return(RedirectToAction("Index"));
                }
            }
            // TODO Create some kind of parent validation exception containing error property
            catch (FixtureTeamsTheSameException)
            {
                ErrorMessage(FormMessages.FixtureTeamsTheSame);
            }
            catch (FixtureRefereesTheSameException)
            {
                ErrorMessage(FormMessages.FixtureRefereesTheSame);
            }

            PopulateStaticData(model);

            return(View(model));
        }