Ejemplo n.º 1
0
        public Result Handle(AddBetterToTournament command)
        {
            Tournament tournament = _tournamentRepository.GetTournamentById(command.TournamentId);

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

            User user = _userRepository.GetUserById(command.UserId);

            if (user == null)
            {
                return(Result.Failure($"Could not add better to tournament with given user ({ command.UserId }). Tournament ({ command.TournamentId }) not found."));
            }

            Better better = _tournamentRepository.AddBetterToTournament(tournament, user);

            if (better == null)
            {
                return(Result.Failure($"Could not add better to tournament with given user ({ command.UserId })."));
            }

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