private async Task ProcessDeploymentsForProjectsRelease(SyncJobCompositeModel syncJobCompositeModel, SpaceModel space, ProjectModel project, ReleaseModel releaseModel) { await LogInformation($"Getting all the deployments for {syncJobCompositeModel.InstanceModel.Name}:{space.Name}:{project.Name}:{releaseModel.Version}", syncJobCompositeModel); var octopusList = await _octopusRepository.GetAllDeploymentsForReleaseAsync(syncJobCompositeModel.InstanceModel, space, project, releaseModel, syncJobCompositeModel.EnvironmentDictionary, syncJobCompositeModel.TenantDictionary); await LogInformation($"{octopusList.Count} deployments(s) found in {syncJobCompositeModel.InstanceModel.Name}:{space.Name}:{project.Name}:{releaseModel.Version}", syncJobCompositeModel); foreach (var item in octopusList) { await LogInformation($"Checking to see if deployment {item.OctopusId}:{item.Name} already exists", syncJobCompositeModel); var itemModel = await _deploymentRepository.GetByOctopusIdAsync(item.OctopusId, releaseModel.Id); await LogInformation($"{(itemModel != null ? "Deployment already exists, updating" : "Unable to find deployment, creating")}", syncJobCompositeModel); item.Id = itemModel?.Id ?? 0; await LogInformation($"Saving deployment {item.OctopusId}:{item.Name} to the database", syncJobCompositeModel); var modelToTrack = item.Id > 0 ? await _deploymentRepository.UpdateAsync(item) : await _deploymentRepository.InsertAsync(item); } }
public Task <DeploymentModel> Insert(int releaseId, DeploymentModel model) { model.ReleaseId = releaseId; return(_repository.InsertAsync(model)); }