public ActionResult CreateSeason() { Season nextSeason = competitionService.CreateNextSeason(competitionService.GetCurrentSeason()); if (nextSeason == null) { ErrorMessage(FormMessages.SeasonCreateCurrentYearFail); return(View("Create")); } // Save the season to the database competitionService.SaveSeason(nextSeason); competitionService.Commit(); SuccessMessage(FormMessages.SeasonCreateSuccess); return(RedirectToAction("Create", "Leagues")); }
public ActionResult CheckLateMatchResults() { int penaltyPoints = 0; List <Fixture> lateResults = null; List <string> penaltyResults = new List <string>(); string output; TeamLeague teamLeague = null; try { using (TransactionScope scope = new TransactionScope()) { penaltyPoints = Int32.Parse(optionService.GetByName(Option.SCHEDULE_LATE_RESULT_PEN_POINTS)); // Get fixtures for current season with late match results lateResults = fixtureService.GetFixturesThatCanBePenalised(competitionService.GetCurrentSeason().Id); // Loop through results and check whether they have penalties already foreach (Fixture fixture in lateResults) { if (!penaltyService.DoesPenaltyExist(fixture.Id, fixture.HomeTeamLeague.Team.Id)) { output = fixture.HomeTeamLeague.TeamNameLong + " penalised " + penaltyPoints + " point(s) for late match result vs " + fixture.AwayTeamLeague.TeamNameLong + " on " + fixture.FixtureDate.ToShortDateString() + " *** AUTOMATIC INSERT"; // Penalty desn't exist, so insert one penaltyService.Insert( new Penalty(fixture.HomeTeamLeague.League, fixture.HomeTeamLeague.Team, penaltyPoints, output, fixture) ); // Too many fecking commits here penaltyService.Commit(); // Update team stats. Slight overkill, but there we go teamLeague = penaltyService.UpdateTeamLeaguePenaltyPoints(fixture.HomeTeamLeague.League.Id, fixture.HomeTeamLeague.Team.Id); penaltyService.Commit(); teamLeague = this.matchResultService.UpdateTeamLeagueStats(teamLeague.Id); this.matchResultService.Commit(); competitionService.UpdateTeamLeague(teamLeague); competitionService.Commit(); penaltyResults.Add(output); } } scope.Complete(); } ViewData["Results"] = penaltyResults; } catch (Exception ex) { Console.WriteLine(ex.Message); ViewData["Exception"] = ex; } return(View()); }