public async Task <IEnumerable <PageBlockTypeDisplayModelMapperOutput> > MapAsync( IReadOnlyCollection <PageBlockTypeDisplayModelMapperInput <ImageDataModel> > inputCollection, PublishStatusQuery publishStatusQuery ) { var imageAssetIds = inputCollection.SelectDistinctModelValuesWithoutEmpty(i => i.ImageId); var imagesQuery = new GetImageAssetRenderDetailsByIdRangeQuery(imageAssetIds); var images = await _queryExecutor.ExecuteAsync(imagesQuery); var results = new List <PageBlockTypeDisplayModelMapperOutput>(inputCollection.Count); foreach (var input in inputCollection) { var output = new ImageDisplayModel() { AltText = input.DataModel.AltText, LinkPath = input.DataModel.LinkPath, LinkTarget = input.DataModel.LinkTarget }; var image = images.GetOrDefault(input.DataModel.ImageId); output.Source = _imageAssetRouteLibrary.ImageAsset(image); results.Add(input.CreateOutput(output)); } return(results); }
public async Task <IDictionary <int, ImageAssetRenderDetails> > ExecuteAsync(GetImageAssetRenderDetailsByIdRangeQuery query, IExecutionContext executionContext) { var cachedResults = QueryCache(query.ImageAssetIds); var missingResultsQuery = QueryDb(cachedResults); List <ImageAssetRenderDetails> missingResults = null; if (missingResultsQuery != null) { var dbMissingResults = await missingResultsQuery.ToListAsync(); missingResults = dbMissingResults .Select(_imageAssetRenderDetailsMapper.Map) .ToList(); } return(AddResultsToCacheAndReturnResult(cachedResults, missingResults)); }
public IEnumerable <IPermissionApplication> GetPermissions(GetImageAssetRenderDetailsByIdRangeQuery query) { yield return(new ImageAssetReadPermission()); }