private async Task HandleSaveSnapshot(HttpContext context, ConfigServerOptions options) { if (context.Request.Method != "POST") { httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context); return; } var command = await context.GetObjectFromJsonBodyAsync <CreateSnapshotCommand>(); var commmandResult = await commandBus.SubmitAsync(command); await httpResponseFactory.BuildResponseFromCommandResult(context, commmandResult); }
private async Task HandlePost(HttpContext context) { var data = await context.GetObjectFromJsonBodyAsync <ConfigurationClientPayload>(); var commandResult = await commandBus.SubmitAsync(new CreateUpdateClientCommand(data)); await httpResponseFactory.BuildResponseFromCommandResult(context, commandResult); }
private async Task HandleUploadConfigurationSet(HttpContext context, string configSetName, ConfigurationClient client) { var configSet = configCollection.SingleOrDefault(c => configSetName.Equals(c.ConfigSetType.Name, StringComparison.OrdinalIgnoreCase)); if (configSet == null) { httpResponseFactory.BuildNotFoundStatusResponse(context); return; } var json = await context.ReadBodyTextAsync(); var result = await commandBus.SubmitAsync(new UpdateConfigurationSetFromJsonUploadCommand(BuildIdentity(client), configSet.ConfigSetType, json)); await httpResponseFactory.BuildResponseFromCommandResult(context, result); return; }
private async Task HandleGroupSaveRequest(HttpContext context) { var group = await context.GetObjectFromJsonBodyAsync <ConfigurationClientGroup>(); var result = await commandBus.SubmitAsync(new CreateUpdateClientGroupCommand(group)); await httpResponseFactory.BuildResponseFromCommandResult(context, result); }
private async Task HandlePostRequest(HttpContext context, ConfigurationClient client, string configType) { var configModel = configCollection.SelectMany(s => s.Configs).SingleOrDefault(s => s.Type.Name.Equals(configType, StringComparison.OrdinalIgnoreCase)); if (configModel == null) { httpResponseFactory.BuildNotFoundStatusResponse(context); return; } var command = new UpdateConfigurationFromEditorCommand(new ConfigurationIdentity(client, configCollection.GetVersion()), configModel.Type, await context.ReadBodyTextAsync()); var result = await commandBus.SubmitAsync(command); await httpResponseFactory.BuildResponseFromCommandResult(context, result); }