public async Task <IActionResult> Get(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 providerData = await providerDataRepository .GetAsync(providerDataId) .ConfigureAwait(false); if (providerData is null) { return(ErrorResult .NotFound($"A Provider Data item with the ID '{providerDataId}' could not be found") .ActionResult()); } var returnData = providerData.PopulateExternalModel(); return(DataResult <ProviderData> .Ok(returnData) .ActionResult()); }
public async Task <IActionResult> Get([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 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 (!project.Type.Providers.Any(p => p.Id.Equals(provider.Id, StringComparison.OrdinalIgnoreCase))) { return(ErrorResult .NotFound($"A Provider with the ID '{ProviderId}' could not be found on the Project '{ProjectId}'") .ToActionResult()); } var providerData = await providerDataRepository .GetAsync(providerDataId) .ConfigureAwait(false); if (providerData is null) { return(ErrorResult .NotFound($"A Provider Data item with the ID '{providerDataId}' could not be found") .ToActionResult()); } var returnData = providerData.PopulateExternalModel(); return(DataResult <ProviderData> .Ok(returnData) .ToActionResult()); }
public async Task <IActionResult> Delete( [HttpTrigger(AuthorizationLevel.Function, "delete", Route = "data/providerData/{providerDataId}")] HttpRequest httpRequest, string providerDataId) { if (httpRequest is null) { throw new ArgumentNullException(nameof(httpRequest)); } if (providerDataId is null) { throw new ArgumentNullException(nameof(providerDataId)); } var providerData = await providerDataRepository .GetAsync(providerDataId) .ConfigureAwait(false); if (providerData is null) { return(new NotFoundResult()); } await providerDataRepository .RemoveAsync(providerData) .ConfigureAwait(false); return(new OkObjectResult(providerData)); }