public async Task InvokeAsync( HttpContext context, IAssetStorage assetStore, JsonService jsonService) { AssetQuery query = await jsonService.Deserialize <AssetQuery>(context.Request.Body); QueryResult <Asset> assets = await assetStore.GetAssetsAsync(query); QueryResult <RestAsset> queryResult = new QueryResult <RestAsset>(); queryResult.Offset = assets.Offset; queryResult.Count = assets.Count; queryResult.TotalCount = assets.TotalCount; queryResult.Items = assets.Items.Select(x => x.ToRest()).ToList(); string json = jsonService.Serialize(queryResult); await context.Response.WriteAsync(json); }