public IActionResult GetAgent(int id) { try { var agents = serviceAgent.GetAgent(id); var agentResource = mapper.Map <AgentResource>(agents); if (agents == null) { return(NotFound()); } else { return(Ok(agentResource)); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }