public async Task SeedAsync(CancellationToken cancellationToken) { var testTarget = new DeploymentTarget("TestTarget", "Test target", "MilouDeployerWebTest", allowExplicitPreRelease: false, autoDeployEnabled: true, targetDirectory: Environment.GetEnvironmentVariable("TestDeploymentTargetPath"), uri: Environment.GetEnvironmentVariable("TestDeploymentUri"), emailNotificationAddresses: new StringValues("*****@*****.**"), enabled: true); var createTarget = new CreateTarget(testTarget.Id, testTarget.Name); await _mediator.Send(createTarget, cancellationToken); var updateDeploymentTarget = new UpdateDeploymentTarget(testTarget.Id, testTarget.AllowPreRelease, testTarget.Url, testTarget.PackageId, autoDeployEnabled: testTarget.AutoDeployEnabled, targetDirectory: testTarget.TargetDirectory, enabled: true); await _mediator.Send(updateDeploymentTarget, cancellationToken); }
public async Task <UpdateDeploymentTargetResult> Handle( UpdateDeploymentTarget request, CancellationToken cancellationToken) { using (IDocumentSession session = _documentStore.OpenSession()) { DeploymentTargetData data = await session.LoadAsync <DeploymentTargetData>(request.Id, cancellationToken); if (data is null) { return(new UpdateDeploymentTargetResult(new ValidationError("Not found"))); } data.PackageId = request.PackageId; data.Url = request.Url; data.IisSiteName = request.IisSiteName; data.AllowExplicitPreRelease = request.AllowExplicitPreRelease; data.NuGetPackageSource = request.NugetPackageSource; data.NuGetConfigFile = request.NugetConfigFile; data.AutoDeployEnabled = request.AutoDeployEnabled; data.PublishSettingsXml = request.PublishSettingsXml; data.TargetDirectory = request.TargetDirectory; data.WebConfigTransform = request.WebConfigTransform; data.ExcludedFilePatterns = request.ExcludedFilePatterns; data.Enabled = request.Enabled; session.Store(data); await session.SaveChangesAsync(cancellationToken); } _logger.Information("Updated target with id {Id}", request.Id); return(new UpdateDeploymentTargetResult()); }
public async Task <ActionResult <UpdateDeploymentTargetResult> > Edit( [FromBody] UpdateDeploymentTarget updateDeploymentTarget, [FromServices] IMediator mediator) { if (updateDeploymentTarget is null) { return(BadRequest($"Model of type {typeof(UpdateDeploymentTarget)} is null")); } if (!updateDeploymentTarget.IsValid) { return(BadRequest($"Model of type {typeof(UpdateDeploymentTarget)} {updateDeploymentTarget} is null")); } UpdateDeploymentTargetResult updateDeploymentTargetResult = await mediator.Send(updateDeploymentTarget); return(updateDeploymentTargetResult); }
public async Task SeedAsync(CancellationToken cancellationToken) { if (!_environmentVariables.Variables.ContainsKey("TestDeploymentTargetPath")) { return; } var testTarget = new DeploymentTarget( new DeploymentTargetId("TestTarget"), "Test target", "MilouDeployerWebTest", allowExplicitPreRelease: false, autoDeployEnabled: true, targetDirectory: _environmentVariables.Variables["TestDeploymentTargetPath"], url: _environmentVariables.Variables["TestDeploymentUri"].ParseUriOrDefault(), emailNotificationAddresses: new StringValues("*****@*****.**"), enabled: true); var createTarget = new CreateTarget(testTarget.Id.TargetId, testTarget.Name); await _mediator.Send(createTarget, cancellationToken); string nugetConfigFile = _keyValueConfiguration[ConfigurationConstants.NugetConfigFile]; var updateDeploymentTarget = new UpdateDeploymentTarget( testTarget.Id, testTarget.AllowPreRelease, testTarget.Url?.ToString(), testTarget.PackageId, autoDeployEnabled: testTarget.AutoDeployEnabled, targetDirectory: testTarget.TargetDirectory, nugetConfigFile: nugetConfigFile); await _mediator.Send(updateDeploymentTarget, cancellationToken); var enableTarget = new EnableTarget(testTarget.Id.TargetId); await _mediator.Send(enableTarget, cancellationToken); }