public async Task <ImageAssetRenderDetails> ExecuteAsync(GetImageAssetRenderDetailsByIdQuery query, IExecutionContext executionContext)
        {
            var asset = await _imageAssetCache.GetOrAddAsync(query.ImageAssetId, async() =>
            {
                var dbResult = await Query(query.ImageAssetId).SingleOrDefaultAsync();
                var result   = _imageAssetRenderDetailsMapper.Map(dbResult);
                return(result);
            });

            return(asset);
        }
示例#2
0
        /// <summary>
        /// Maps an EF PageVersion record from the db into an OpenGraphData
        /// object.
        /// </summary>
        /// <param name="dbPageVersion">PageVersion record from the database, must include the OpenGraphImageAsset property.</param>
        public virtual OpenGraphData Map(PageVersion dbPageVersion)
        {
            var result = new OpenGraphData()
            {
                Description = dbPageVersion.OpenGraphDescription,
                Title       = dbPageVersion.OpenGraphTitle
            };

            if (dbPageVersion.OpenGraphImageId.HasValue && dbPageVersion.OpenGraphImageAsset == null)
            {
                throw new Exception($"{nameof(PageVersion)}.{nameof(dbPageVersion.OpenGraphImageAsset)} must be included in the EF query if using {nameof(OpenGraphDataMapper)}. ");
            }

            if (dbPageVersion.OpenGraphImageAsset != null)
            {
                result.Image = _imageAssetRenderDetailsMapper.Map(dbPageVersion.OpenGraphImageAsset);
            }

            return(result);
        }