public Task <IActionResult> Get() => EnsureProviderAsync(async provider => { var dataDocuments = await providerDataRepository .ListAsync(provider.Id) .ToListAsync() .ConfigureAwait(false); var data = dataDocuments.Select(d => d.PopulateExternalModel()).ToList(); return(DataResult <List <ProviderData> > .Ok(data) .ToActionResult()); });
public async Task <IActionResult> Get([FromQuery] bool includeShared) { 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 data = await providerDataRepository .ListAsync(provider.Id, project.Id, includeShared) .ToListAsync() .ConfigureAwait(false); var returnData = data.Select(d => d.PopulateExternalModel()).ToList(); return(DataResult <List <ProviderData> > .Ok(returnData) .ToActionResult()); }
public Task <IActionResult> Get([FromQuery] bool includeShared) => EnsureProjectAndProviderAsync(async(project, provider) => { if (!project.Type.Providers.Any(p => p.Id.Equals(provider.Id, StringComparison.OrdinalIgnoreCase))) { return(ErrorResult .NotFound($"A Provider with the ID '{provider.Id}' could not be found on the Project '{project.Id}'") .ToActionResult()); } var dataDocuments = await providerDataRepository .ListAsync(provider.Id, project.Id, includeShared) .ToListAsync() .ConfigureAwait(false); var data = dataDocuments.Select(d => d.PopulateExternalModel()).ToList(); return(DataResult <List <ProviderData> > .Ok(data) .ToActionResult()); });
public async Task <IActionResult> Get() { 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 data = await providerDataRepository .ListAsync(provider.Id) .ToListAsync() .ConfigureAwait(false); var returnData = data.Select(d => d.PopulateExternalModel()).ToList(); return(DataResult <List <ProviderData> > .Ok(returnData) .ActionResult()); }