コード例 #1
0
        public Result Handle(RenameRoundInTournament command)
        {
            Tournament tournament = _tournamentRepository.GetTournamentById(command.TournamentId);

            if (tournament == null)
            {
                return(Result.Failure($"Could not rename round ({ command.RoundId }) to { command.NewRoundName } in tournament ({ command.TournamentId }). Tournament not found."));
            }

            RoundBase round = tournament.GetRoundById(command.RoundId);

            if (round == null)
            {
                return(Result.Failure($"Could not rename round ({ command.RoundId }) to { command.NewRoundName } in tournament ({ command.TournamentId }). Round not found."));
            }

            bool renameSuccessful = _tournamentRepository.RenameRoundInTournament(round, command.NewRoundName);

            if (!renameSuccessful)
            {
                return(Result.Failure($"Could not rename round ({ command.RoundId }) to { command.NewRoundName } in tournament ({ command.TournamentId })."));
            }

            _tournamentRepository.Save();
            return(Result.Success());
        }