Example #1
0
        public override async Task <ResourceDto> GetAsync(Guid id)
        {
            var resource = await GetEntityByIdAsync(id);

            if (!resource.IsPublished && !await _categoryDataPermissionProvider.IsCurrentUserAllowedToManageAsync(resource.CategoryId))
            {
                throw new EntityNotFoundException(typeof(Resource), id);
            }

            var dto = MapToGetOutputDto(resource);

            dto.IsAuthorized = await _resourceUserRepository.FindAsync(id, CurrentUser.GetId()) != null;

            return(dto);
        }
Example #2
0
 protected virtual async Task <bool> IsCurrentUserAuthorizedToReadAsync(Guid resourceId)
 {
     return(CurrentUser.Id.HasValue &&
            await _resourceUserRepository.FindAsync(resourceId, CurrentUser.Id.Value) != null);
 }