예제 #1
0
        /// <summary>
        /// Provides concept and complete ancestry for concepts matching the search term.
        /// </summary>
        /// <returns>Matching concepts and ancestry.</returns>
        /// <param name="root">Optional root id to search within.</param>
        /// <param name="term">Search term to match on.</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="DbException"/>
        public async Task <IEnumerable <Concept> > GetAncestryBySearchTermAsync(Guid?root, string term)
        {
            Ensure.NotNull(term, nameof(term));

            log.LogInformation("Getting concept with ancestry by term. Root:{Root} Term:{Term}", root, term);
            var terms = term.Split(' ');

            return(await reader.GetWithParentsBySearchTermAsync(root, terms));
        }
예제 #2
0
        public async Task <ActionResult <IEnumerable <ConceptDTO> > > SearchParents(
            [FromQuery] string searchTerm,
            [FromQuery] Guid?rootId,
            [FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var terms    = searchTerm.Split(' ');
                var concepts = await conceptReader.GetWithParentsBySearchTermAsync(rootId, terms);

                return(Ok(concepts.Select(c => new ConceptDTO(c))));
            }
            catch (Exception ex)
            {
                log.LogError("Could not search for concepts by term. Term:{Term} RootId:{RootId} Error:{Error}", searchTerm, rootId, ex.Message);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }