Esempio n. 1
0
 /// <summary>
 /// Provides a concept by id.
 /// </summary>
 /// <returns>The concept if found, else null.</returns>
 /// <param name="id">Concept id.</param>
 /// <exception cref="LeafRPCException"/>
 /// <exception cref="DbException"/>
 public async Task <Concept> GetAsync(Guid id)
 {
     log.LogInformation("Getting Concept. Id:{Id}", id);
     try
     {
         return(await reader.GetAsync(id));
     }
     catch (DbException de)
     {
         log.LogError("Failed to get concept by Id. Id:{Id} Error:{Error}", id, de.Message);
         de.MapThrow();
         throw;
     }
 }
Esempio n. 2
0
        public async Task <ActionResult <ConceptDTO> > Single(Guid ident, [FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var concept = await conceptReader.GetAsync(ident);

                if (concept == null)
                {
                    return(NotFound());
                }

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