public IActionResult Get(int id) { ProdutoBO produtoBO; ProdutoModel produto; ObjectResult response; try { _log.LogInformation($"Starting Get( {id} )"); produtoBO = new ProdutoBO(_loggerFactory, _config); produto = produtoBO.Get(id); if (produto != null) { response = Ok(produto); } else { response = NotFound(string.Empty); } _log.LogInformation($"Finishing Get( {id} )"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }
public IActionResult Get(string name = null) { ProdutoBO produtoBO; List <ProdutoModel> enderecos; ObjectResult response; try { _log.LogInformation("Starting Get()"); produtoBO = new ProdutoBO(_loggerFactory, _config); enderecos = produtoBO.Get(name); response = Ok(enderecos); _log.LogInformation($"Finishing Get() with '{enderecos.Count}' results"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }