public async Task AddAdminRequest(Guid differentUserId, Guid competitionId)
        {
            var existingAdminRequest = await _adminRequestRepo.Get(differentUserId, competitionId);

            existingAdminRequest.EnsureDoesNotExist();

            var existingAdmin = await _adminRepo.Get(differentUserId, competitionId);

            existingAdmin.EnsureDoesNotExist();

            _adminRequestRepo.Create(new AdminRequest(differentUserId, competitionId));
            await _adminRequestRepo.Save();
        }
예제 #2
0
        public async Task <CompetitionResponse> AddAdminToCompetition(Guid userId, Guid competitionId)
        {
            var existingAdmin = await _adminRepo.Get(userId, competitionId);

            existingAdmin.EnsureDoesNotExist();

            var existingAdminRequest = await _adminRequestRepo.Get(userId, competitionId);

            existingAdminRequest.EnsureExists("Admin request not found.");

            _adminRepo.Create(new Admin(userId, competitionId));
            _adminRequestRepo.Delete(existingAdminRequest);
            await _adminRepo.Save();

            //return competition with admin information
            var competition = await _competitionRepo.GetWithInfo(competitionId);

            return(new CompetitionResponse(competition, true, userId));
        }