TContext EndRound(TContext context, CommandEvent commandEvent) { var command = new EndRoundCommand(); return(Fire( context, TournamentCommand.EndRound, () => ContextBuilder.ProcessCommand(context, command) )); }
public CommandResult <SwissTournamentContext, bool> ProcessCommand(SwissTournamentContext context, EndRoundCommand command) { var nextRoundNumber = (context.ActiveRound ?? 1) + 1; // Check the number of rounds // If round number + 1 > the number of rounds, tournament is over // Otherwise just move to next round var allRoundsCompleted = nextRoundNumber > StatisticsProvider.GetNumberOfRoundsInTournament(context); if (allRoundsCompleted) { return(new RoundCompletedResult <SwissTournamentContext>(context, allRoundsCompleted)); } else { return(new RoundCompletedResult <SwissTournamentContext>( new SwissTournamentContext(context, activeRound: nextRoundNumber), allRoundsCompleted )); } }