Ejemplo n.º 1
0
        public async Task <bool> IsAuthorizedToSeeProjectAsync(long projectId, long?userId)
        {
            var project = await GetByIdAsync(projectId);

            if (!project.IsPrivate)
            {
                return(true);
            }

            if (!userId.HasValue)
            {
                return(false);
            }

            if (project.AuthorId == userId.Value)
            {
                return(true);
            }

            var user = await _userRepository.GetByIdAsync(userId.Value);

            var isAdmin = await _userRepository.HasRoleAsync(user.Address, RoleType.Admin);

            if (isAdmin)
            {
                return(true);
            }

            if (project.Scoring == null)
            {
                return(false);
            }

            var offersQuery = new OffersQuery(0, 1, expertId: userId, scoringId: project.Scoring.Id);
            var offers      = await _scoringOffersRepository.GetAsync(offersQuery, _clock.UtcNow);

            return(offers.Any());
        }
Ejemplo n.º 2
0
 public Task <PagingCollection <ScoringOfferDetails> > QueryOffersAsync(OffersQuery query, DateTimeOffset now)
 => _scoringOffersRepository.GetAsync(query, now);