public async Task <IActionResult> Delete(string id) { try { Agent agent = _agentRepo.GetOne(new Guid(id)); if (agent == null) { throw new EntityDoesNotExistException("No agent was found with the specified agent id"); } _agentManager.DeleteAgentDependencies(agent); var result = await base.DeleteEntity(id); await _webhookPublisher.PublishAsync("Agents.AgentDeleted", id, agent.Name).ConfigureAwait(false); return(result); } catch (Exception ex) { return(ex.GetActionResult()); } }