コード例 #1
0
        public virtual async Task <IAssetEntity> FindAssetAsync(Guid id)
        {
            var asset = cachedAssets.GetOrDefault(id);

            if (asset == null)
            {
                asset = await assetQuery.FindAssetAsync(context, id);

                if (asset != null)
                {
                    cachedAssets[asset.Id] = asset;
                }
            }

            return(asset);
        }
コード例 #2
0
        public async Task <IActionResult> GetAsset(string app, Guid id)
        {
            var asset = await assetQuery.FindAssetAsync(Context, id);

            if (asset == null)
            {
                return(NotFound());
            }

            var response = Deferred.Response(() =>
            {
                return(AssetDto.FromAsset(asset, this, app));
            });

            return(Ok(response));
        }
コード例 #3
0
ファイル: AssetsController.cs プロジェクト: zxbe/squidex
        public async Task <IActionResult> GetAsset(string app, Guid id)
        {
            var context = Context();

            var entity = await assetQuery.FindAssetAsync(context, id);

            if (entity == null)
            {
                return(NotFound());
            }

            var response = AssetDto.FromAsset(entity);

            Response.Headers["ETag"]          = entity.Version.ToString();
            Response.Headers["Surrogate-Key"] = entity.Id.ToString();

            return(Ok(response));
        }
コード例 #4
0
ファイル: AssetsController.cs プロジェクト: xixaoly/squidex
        public async Task <IActionResult> GetAsset(string app, Guid id)
        {
            var asset = await assetQuery.FindAssetAsync(id);

            if (asset == null)
            {
                return(NotFound());
            }

            var response = AssetDto.FromAsset(asset, this, app);

            if (controllerOptions.Value.EnableSurrogateKeys)
            {
                Response.Headers["Surrogate-Key"] = asset.Id.ToString();
            }

            Response.Headers[HeaderNames.ETag] = asset.Version.ToString();

            return(Ok(response));
        }
コード例 #5
0
        public async Task <IActionResult> GetAsset(string app, Guid id)
        {
            var asset = await assetQuery.FindAssetAsync(Context, id);

            if (asset == null)
            {
                return(NotFound());
            }

            var response = Deferred.Response(() =>
            {
                return(AssetDto.FromAsset(asset, this, app));
            });

            if (controllerOptions.EnableSurrogateKeys)
            {
                Response.Headers["Surrogate-Key"] = asset.ToSurrogateKey();
            }

            Response.Headers[HeaderNames.ETag] = asset.ToEtag();

            return(Ok(response));
        }