public async Task InvokeAsync( HttpContext context, IWebHookStorage contentStore, JsonService jsonService) { Guid id = Guid.Parse((string)context.GetRouteValue("id")); WebHook result = await contentStore.GetAsync(id); RestWebHook restModel = result.ToRest(); string json = jsonService.Serialize(restModel); await context.Response.WriteAsync(json); }
public async Task InvokeAsync( HttpContext context, IWebHookStorage schemaStorage, JsonService jsonService) { QueryResult <WebHook> items = await schemaStorage .QueryAsync(new WebHookQuery()); QueryResult <RestWebHook> restQueryResult = new QueryResult <RestWebHook>(); restQueryResult.Items = items.Items.Select(x => x.ToRest()).ToList(); restQueryResult.Offset = items.Offset; restQueryResult.Count = items.Count; restQueryResult.TotalCount = items.TotalCount; string json = jsonService.Serialize(restQueryResult); await context.Response.WriteAsync(json); }
public async Task InvokeAsync( HttpContext context, IWebHookStorage contentStore, JsonService jsonService) { RestWebHook input = await jsonService.Deserialize <RestWebHook>(context.Request.Body); WebHook model = input.ToModel(); await contentStore.CreateAsync(model); ResourceCreated result = new ResourceCreated() { Id = model.Id }; string json = jsonService.Serialize(result); await context.Response.WriteAsync(json); }