public Result Handle(AddRoundToTournament command) { Tournament tournament = _tournamentRepository.GetTournamentById(command.TournamentId); if (tournament == null) { return(Result.Failure($"Could not add round ({ command.RoundType }) to tournament. Tournament ({ command.TournamentId }) not found.")); } string parsedRoundType = StringUtility.ToUpperNoSpaces(command.RoundType); RoundBase round; switch (parsedRoundType) { case "BRACKET": round = _tournamentRepository.AddBracketRoundToTournament(tournament); break; case "DUALTOURNAMENT": round = _tournamentRepository.AddDualTournamentRoundToTournament(tournament); break; case "ROUNDROBIN": round = _tournamentRepository.AddRoundRobinRoundToTournament(tournament); break; default: return(Result.Failure($"Could not add round ({ command.RoundType }) to tournament. Invalid round type ({ command.RoundType }) given.")); } if (round == null) { return(Result.Failure($"Could not add round ({ command.RoundType }) to tournament.")); } _tournamentRepository.Save(); return(Result.Success()); }