Ejemplo n.º 1
0
        public static void SetCurrentRace(int tournamentID, int raceNum)
        {
            IRlmRepository repo = RepositoryManager.GetDefaultRepository();

            IRace previousRace = GetCurrentRace(tournamentID);

            lock (_lock)
            {
                Tournament tournament = repo.LoadTournament(tournamentID);
                Race       race       = tournament.RaceData.Where(r => r.RaceNumber == raceNum).Single();
                tournament.CurrentRace = raceNum;
                repo.SaveTournament(tournament);
            }

            CurrentRaceChanged?.Invoke(tournamentID, new CurrentRaceChangedEventArgs(previousRace, GetCurrentRace(tournamentID)));
            NextRacesUpdated?.Invoke(tournamentID, new NextRacesUpdatedEventArgs(GetNextRaces(tournamentID)));
        }
Ejemplo n.º 2
0
        public static RlmGetRacesResponse GenerateRaces(int tournamentID)
        {
            IRlmRepository      repo   = RepositoryManager.GetDefaultRepository();
            RlmGetRacesResponse result = null;

            lock (_lock)
            {
                Tournament tournament = repo.LoadTournament(tournamentID);

                // generate the races
                TournamentManager.GenerateRaces(ref tournament);

                repo.SaveTournament(tournament);
                result = GetRaces(tournament);
            }

            RacesUpdated?.Invoke(tournamentID, new RacesUpdatedEventArgs(result));
            CurrentRaceChanged?.Invoke(tournamentID, new CurrentRaceChangedEventArgs(null, GetCurrentRace(tournamentID)));
            //RaceUpdated?.Invoke(tournamentID, new RaceUpdatedEventArgs(GetCurrentRace(tournamentID)));
            NextRacesUpdated?.Invoke(tournamentID, new NextRacesUpdatedEventArgs(GetNextRaces(tournamentID)));
            StandingsUpdated?.Invoke(tournamentID, new StandingsUpdatedEventArgs(GetStandings(tournamentID)));

            return(result);
        }