public async Task ReturnsMappedData() { var uniqueData = UNIQUE_PREFIX + nameof(ReturnsMappedData); using var app = _appFactory.Create(); var directory1Id = await app.TestData.PageDirectories().AddAsync(uniqueData); var directory2Id = await app.TestData.PageDirectories().AddAsync(uniqueData + "-sub", directory1Id); var contentRepository = app.Services.GetContentRepositoryWithElevatedPermissions(); var query = new GetPageDirectoryEntityMicroSummariesByIdRangeQuery(new int[] { directory1Id, directory2Id }); var directoryLookup = await contentRepository.ExecuteQueryAsync(query); var directory1 = directoryLookup.GetOrDefault(directory1Id); var directory2 = directoryLookup.GetOrDefault(directory2Id); using (new AssertionScope()) { directoryLookup.Should().NotBeNull(); directoryLookup.Count.Should().Be(2); directory1.Should().NotBeNull(); directory1.EntityDefinitionCode.Should().Be(PageDirectoryEntityDefinition.DefinitionCode); directory1.EntityDefinitionName.Should().Be(new PageDirectoryEntityDefinition().Name); directory1.IsPreviousVersion.Should().BeFalse(); directory1.RootEntityId.Should().Be(directory1Id); directory1.RootEntityTitle.Should().Be(uniqueData); directory2.Should().NotBeNull(); } }
private IQueryable <RootEntityMicroSummary> Query(GetPageDirectoryEntityMicroSummariesByIdRangeQuery query) { var definition = _entityDefinitionRepository.GetByCode(PageDirectoryEntityDefinition.DefinitionCode); var dbQuery = _dbContext .PageDirectories .AsNoTracking() .Where(d => query.PageDirectoryIds.Contains(d.PageDirectoryId)) .Select(d => new RootEntityMicroSummary() { RootEntityId = d.PageDirectoryId, RootEntityTitle = d.Name, EntityDefinitionName = definition.Name, EntityDefinitionCode = definition.EntityDefinitionCode }); return(dbQuery); }
public async Task <IDictionary <int, RootEntityMicroSummary> > ExecuteAsync(GetPageDirectoryEntityMicroSummariesByIdRangeQuery query, IExecutionContext executionContext) { var definition = _entityDefinitionRepository.GetRequiredByCode(PageDirectoryEntityDefinition.DefinitionCode); var results = await _dbContext .PageDirectories .AsNoTracking() .Where(d => query.PageDirectoryIds.Contains(d.PageDirectoryId)) .Select(d => new RootEntityMicroSummary() { RootEntityId = d.PageDirectoryId, RootEntityTitle = d.Name, EntityDefinitionName = definition.Name, EntityDefinitionCode = definition.EntityDefinitionCode }) .ToDictionaryAsync(e => e.RootEntityId); return(results); }
public IEnumerable <IPermissionApplication> GetPermissions(GetPageDirectoryEntityMicroSummariesByIdRangeQuery query) { yield return(new PageDirectoryReadPermission()); }
public async Task <IDictionary <int, RootEntityMicroSummary> > ExecuteAsync(GetPageDirectoryEntityMicroSummariesByIdRangeQuery query, IExecutionContext executionContext) { var results = await Query(query).ToDictionaryAsync(e => e.RootEntityId); return(results); }