public IActionResult Get(int id) { CategoryBO categoryBO; Category category; ObjectResult response; try { _log.LogInformation($"Starting Get( {id} )"); categoryBO = new CategoryBO(_loggerFactory, _config); category = categoryBO.Get(id); if (category != null) { response = Ok(category); } 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) { CategoryBO categoryBO; List <Category> categorys; ObjectResult response; try { _log.LogInformation("Starting Get()"); categoryBO = new CategoryBO(_loggerFactory, _config); categorys = categoryBO.Get(name); response = Ok(categorys); _log.LogInformation($"Finishing Get() with '{categorys.Count}' results"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }