public static RestWebHook ToRest(this WebHook webHook) { RestWebHook restWebHook = new RestWebHook(); restWebHook.Id = webHook.Id; restWebHook.CreatedAt = webHook.CreatedAt; restWebHook.ModifiedAt = webHook.ModifiedAt; restWebHook.Version = webHook.Version; restWebHook.TargetUrl = webHook.TargetUrl; restWebHook.Name = webHook.Name; restWebHook.EventName = webHook.EventName; return(restWebHook); }
public static WebHook ToModel(this RestWebHook restWebHook) { WebHook webHook = new WebHook(); webHook.Id = restWebHook.Id; webHook.CreatedAt = restWebHook.CreatedAt; webHook.ModifiedAt = restWebHook.ModifiedAt; webHook.Version = restWebHook.Version; webHook.TargetUrl = restWebHook.TargetUrl; webHook.Name = restWebHook.Name; webHook.EventName = restWebHook.EventName; return(webHook); }
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 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); }