///<inheritdoc/>

        public async Task <ClubAnnualReportDTO> GetByIdAsync(ClaimsPrincipal claimsPrincipal, int id)
        {
            var clubAnnualReport = await _repositoryWrapper.ClubAnnualReports.GetFirstOrDefaultAsync(
                predicate : a => a.ID == id,
                include : source => source
                .Include(a => a.Club));

            return(await _clubAccessService.HasAccessAsync(claimsPrincipal, clubAnnualReport.Club.ID) ? _mapper.Map <ClubAnnualReport, ClubAnnualReportDTO>(clubAnnualReport)
                : throw new UnauthorizedAccessException());
        }
        public async Task <IActionResult> GetMembers(int ClubId)
        {
            var ClubProfileDto = await _ClubService.GetClubMembersAsync(ClubId);

            if (ClubProfileDto == null)
            {
                return(NotFound());
            }

            var ClubProfile = _mapper.Map <ClubProfileDTO, ClubViewModel>(ClubProfileDto);

            ClubProfile.CanEdit = await _ClubAccessService.HasAccessAsync(User, ClubId);

            return(Ok(new { ClubProfile.Members, ClubProfile.CanEdit, ClubProfile.Name }));
        }
        ///<inheritdoc/>

        public async Task <ClubAnnualReportDTO> GetByIdAsync(ClaimsPrincipal claimsPrincipal, int id)
        {
            var clubAnnualReport = await _repositoryWrapper.ClubAnnualReports.GetFirstOrDefaultAsync(
                predicate : a => a.ID == id,
                include : source => source
                .Include(a => a.Club)
                .ThenInclude(c => c.ClubAdministration)
                .ThenInclude(cb => cb.AdminType)
                .Include(ad => ad.Club)
                .ThenInclude(ac => ac.ClubAdministration)
                .ThenInclude(ar => ar.User)
                .Include(ca => ca.Club)
                .ThenInclude(cm => cm.ClubMembers)
                .ThenInclude(mc => mc.User));

            return(await _clubAccessService.HasAccessAsync(claimsPrincipal, clubAnnualReport.ClubId) ? _mapper.Map <ClubAnnualReport, ClubAnnualReportDTO>(clubAnnualReport)
                : throw new UnauthorizedAccessException());
        }
Exemple #4
0
        /// <inheritdoc />
        public async Task <ClubProfileDTO> GetClubProfileAsync(int ClubId, ClaimsPrincipal user)
        {
            var ClubProfileDto = await GetClubProfileAsync(ClubId);

            var userId = _userManager.GetUserId(user);

            ClubProfileDto.Club.CanCreate = user.IsInRole("Admin");
            ClubProfileDto.Club.CanEdit   = await _ClubAccessService.HasAccessAsync(user, ClubId);

            ClubProfileDto.Club.CanJoin = (await _repoWrapper.ClubMembers
                                           .GetFirstOrDefaultAsync(u => u.User.Id == userId && u.ClubId == ClubId)) == null;

            return(ClubProfileDto);
        }
Exemple #5
0
        /// <inheritdoc />
        public async Task <ClubProfileDTO> GetClubProfileAsync(int ClubId, DataAccessClub.User user)
        {
            var ClubProfileDto = await GetClubProfileAsync(ClubId);

            var userId = await _userManager.GetUserIdAsync(user);

            var userRoles = await _userManager.GetRolesAsync(user);

            ClubProfileDto.Club.CanCreate = userRoles.Contains("Admin");
            ClubProfileDto.Club.CanEdit   = await _clubAccessService.HasAccessAsync(user, ClubId);

            ClubProfileDto.Club.CanJoin = (await _repoWrapper.ClubMembers
                                           .GetFirstOrDefaultAsync(u => u.User.Id == userId && u.ClubId == ClubId)) == null;

            return(ClubProfileDto);
        }