Beispiel #1
0
        public async Task <CompetitionUserResponse> AddParticipationRequest(Guid userId, Guid competitionId)
        {
            var competition = await _competitionRepo.Get(competitionId);

            competition.EnsureExists("Competition not found.");

            var existingParticipationRequest = await _participationRequestRepo.Get(userId, competitionId);

            existingParticipationRequest.EnsureDoesNotExist();

            var existingParticipant = await _participantRepo.Get(userId, competitionId);

            existingParticipant.EnsureDoesNotExist();

            var user = await _userRepo.Get(userId);

            user.EnsureExists("User not found.");

            var participationRequest = new ParticipationRequest(userId, competitionId);

            _participationRequestRepo.Create(participationRequest);
            await _participationRequestRepo.Save();

            return(new CompetitionUserResponse(user));
        }
Beispiel #2
0
        public async Task <ParticipantResponse> AddParticipantToCompetitionAsAdmin(Guid differentUserId, Guid competitionId)
        {
            var participationRequest = await _participationRequestRepo.Get(differentUserId, competitionId);

            participationRequest.EnsureExists("Participation request not found.");

            var participant = new Participant(differentUserId, competitionId);

            _participationRequestRepo.Delete(participationRequest);
            _participantRepo.Create(participant);
            await _participantRepo.Save();

            return(new ParticipantResponse(participant));
        }