public async Task <ComponentTemplate> GetAsync(string organization, string projectId, string id) { var templateId = await ResolveProjectTemplateIdAsync(organization, projectId) .ConfigureAwait(false); var projectTemplate = await projectTemplateRepository .GetAsync(organization, templateId) .ConfigureAwait(false); return(await repositoryService .GetComponentTemplateAsync(projectTemplate, id) .ConfigureAwait(false)); }
public Task <IActionResult> Get([FromRoute] string id) => WithContextAsync <Project>(async(contextUser, project) => { if (string.IsNullOrWhiteSpace(id)) { return(ErrorResult .BadRequest($"The id provided in the url path is invalid. Must be a non-empty string.", ResultErrorCode.ValidationError) .ToActionResult()); } var projectTemplate = await projectTemplateRepository .GetAsync(project.Organization, project.Template) .ConfigureAwait(false); var componentTemplate = await componentTemplateRepository .GetAsync(project.Organization, project.Id, id) .ConfigureAwait(false); if (!(componentTemplate?.ParentId?.Equals(projectTemplate.Id, StringComparison.Ordinal) ?? false)) { return(ErrorResult .NotFound($"A Component Template with the id '{id}' could not be found for Project {project.Id}.") .ToActionResult()); } return(DataResult <ComponentTemplate> .Ok(componentTemplate) .ToActionResult()); });