Esempio n. 1
0
        public async Task <ActionResult <ConceptParentsDTO> > Parents(
            [FromQuery] HashSet <Guid> idents,
            [FromServices] ConceptTreeSearcher searcher)
        {
            try
            {
                var concepts = await searcher.GetAncestryAsync(idents);

                var dto = new ConceptParentsDTO
                {
                    Concepts = concepts.Select(c => new ConceptDTO(c))
                };

                return(Ok(dto));
            }
            catch (ArgumentNullException ane)
            {
                log.LogError("Missing argument. Error:{Error}", ane.Message);
                return(BadRequest());
            }
            catch (Exception ex)
            {
                log.LogError("Failed to retrieve parents of Concepts:{Ids}. Error:{Error}", idents, ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Esempio n. 2
0
        public async Task <ActionResult <ConceptParentsDTO> > Parents(
            [FromQuery] HashSet <Guid> idents,
            [FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var concepts = await conceptReader.GetWithParentsAsync(idents);

                var dto = new ConceptParentsDTO
                {
                    Concepts = concepts.Select(c => new ConceptDTO(c))
                };

                return(Ok(dto));
            }
            catch (Exception ex)
            {
                log.LogError("Could not retrieve parents of Concepts:{Ids}. Error:{Error}", idents, ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }