예제 #1
0
        public Result Handle(AddPlayerToTournament command)
        {
            Tournament tournament = _tournamentRepository.GetTournamentById(command.TournamentId);

            if (tournament == null)
            {
                return(Result.Failure($"Could not add new player ({ command.PlayerName }) to tournament. Tournament ({ command.TournamentId }) not found."));
            }

            PlayerReference playerReference = _tournamentRepository.AddPlayerReference(tournament, command.PlayerName);

            if (playerReference == null)
            {
                return(Result.Failure($"Could not add new player ({ command.PlayerName }) to tournament."));
            }

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