public IActionResult Get(int id) { EnderecoBO enderecoBO; EnderecoModel endereco; ObjectResult response; try { _log.LogInformation($"Starting Get( {id} )"); enderecoBO = new EnderecoBO(_loggerFactory, _config); endereco = enderecoBO.Get(id); if (endereco != null) { response = Ok(endereco); } 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) { EnderecoBO enderecoBO; List <EnderecoModel> enderecos; ObjectResult response; try { _log.LogInformation("Starting Get()"); enderecoBO = new EnderecoBO(_loggerFactory, _config); enderecos = enderecoBO.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); }