public async Task <IActionResult> Delete([FromRoute] string providerDataId) { var provider = await providersRepository .GetAsync(ProviderId) .ConfigureAwait(false); if (provider is null) { return(ErrorResult .NotFound($"A Provider with the ID '{ProviderId}' could not be found in this TeamCloud Instance") .ActionResult()); } var existingProviderData = await providerDataRepository .GetAsync(providerDataId) .ConfigureAwait(false); if (existingProviderData is null) { return(ErrorResult .NotFound($"A Provider Data item with the ID '{providerDataId}' could not be found") .ActionResult()); } _ = await orchestrator .DeleteAsync(existingProviderData) .ConfigureAwait(false); return(DataResult <ProviderData> .NoContent() .ActionResult()); }
public async Task <IActionResult> Delete([FromRoute] string providerDataId) { var provider = await providersRepository .GetAsync(ProviderId) .ConfigureAwait(false); if (provider is null) { return(ErrorResult .NotFound($"A Provider with the ID '{ProviderId}' could not be found in this TeamCloud Instance") .ToActionResult()); } var existingProviderData = await providerDataRepository .GetAsync(providerDataId) .ConfigureAwait(false); if (existingProviderData is null) { return(ErrorResult .NotFound($"A Provider Data item with the ID '{providerDataId}' could not be found") .ToActionResult()); } if (existingProviderData.Scope == ProviderDataScope.System) { return(ErrorResult .BadRequest("The specified Provider Data item is not scoped to a project use the system api to delete.", ResultErrorCode.ValidationError) .ToActionResult()); } var project = await projectsRepository .GetAsync(ProjectId) .ConfigureAwait(false); if (project is null) { return(ErrorResult .NotFound($"A Project with the identifier '{ProjectId}' could not be found in this TeamCloud Instance") .ToActionResult()); } if (!existingProviderData.ProjectId.Equals(project.Id, StringComparison.OrdinalIgnoreCase)) { return(ErrorResult .NotFound($"A Provider Data item with the ID '{providerDataId}' could not be found for project '{ProjectId}'") .ToActionResult()); } _ = await orchestrator .DeleteAsync(existingProviderData) .ConfigureAwait(false); return(DataResult <ProviderData> .NoContent() .ToActionResult()); }
public async Task <IActionResult> Delete(string projectTypeId) { var existingProjectType = await projectTypesRepository .GetAsync(projectTypeId) .ConfigureAwait(false); if (existingProjectType is null) { return(ErrorResult .NotFound($"A ProjectType with the ID '{projectTypeId}' could not be found in this TeamCloud Instance") .ActionResult()); } _ = await orchestrator .DeleteAsync(projectTypeId) .ConfigureAwait(false); return(DataResult <ProjectType> .NoContent() .ActionResult()); }