Last active
April 2, 2020 15:50
-
-
Save gavilanch/d1d1296a7ead28428b49ba4a3b2e9c04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
public ActionResult<IEnumerable<Autor>> Get() | |
{ | |
logger.LogInformation("Obteniendo los autores"); | |
return context.Autores.ToList(); | |
} | |
[HttpGet("{id}")] | |
public async Task<ActionResult<Autor>> Get(int id) | |
{ | |
logger.LogDebug("Buscando autor de id " + id.ToString()); | |
var autor = await context.Autores.FirstOrDefaultAsync(x => x.Id == id); | |
if (autor == null) | |
{ | |
logger.LogWarning($"El autor de Id {id} no ha sido encontrado"); | |
return NotFound(); | |
} | |
return autor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment