Skip to content

Instantly share code, notes, and snippets.

@binerdy
Created February 5, 2020 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binerdy/170057998c5dda7d1984317b39464edb to your computer and use it in GitHub Desktop.
Save binerdy/170057998c5dda7d1984317b39464edb to your computer and use it in GitHub Desktop.
[HttpGet("{id}")]
public async Task<ActionResult<Employee>> GetEmployeeById(long id)
{
try
{
Employee employee = await _employeeRepository.Get(id);
return Ok(employee);
}
catch (EmployeeNotFoundException e)
{
return NotFound(e.Message);
}
catch (ArgumentException e)
{
return BadRequest(e.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment