Exemple #1
0
 /// <summary>
 /// Provides the children of the specified parent concept.
 /// </summary>
 /// <returns>Child concepts.</returns>
 /// <param name="parent">Parent concept id.</param>
 /// <exception cref="LeafRPCException"/>
 /// <exception cref="DbException"/>
 public async Task <IEnumerable <Concept> > GetChildrenAsync(Guid parent)
 {
     log.LogInformation("Getting child concepts. Parent:{Parent}", parent);
     try
     {
         return(await reader.GetChildrenAsync(parent));
     }
     catch (DbException de)
     {
         log.LogError("Failed to get child concepts. ParentId:{ParentId} Error:{Error}", parent, de.Message);
         de.MapThrow();
         throw;
     }
 }
Exemple #2
0
        public async Task <ActionResult <IEnumerable <ConceptDTO> > > Children(Guid ident, [FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var children = await conceptReader.GetChildrenAsync(ident);

                var dtos = children.Select(c => new ConceptDTO(c));
                return(Ok(dtos));
            }
            catch (LeafDbException le)
            {
                return(StatusCode(le.StatusCode));
            }
            catch (Exception ex)
            {
                log.LogError("Could not retrieve children of Concept:{Id}. Error:{Error}", ident, ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }