public async Task <IActionResult> Patch(string id, [FromBody] JsonPatchDocument <Agent> request) { try { Guid entityId = new Guid(id); var existingAgent = repository.GetOne(entityId); if (existingAgent == null) { return(NotFound()); } for (int i = 0; i < request.Operations.Count; i++) { if (request.Operations[i].op.ToString().ToLower() == "replace" && request.Operations[i].path.ToString().ToLower() == "/name") { _agentManager.UpdateAgentName(existingAgent.Name, request.Operations[i].value.ToString().ToLower()); } } var result = await base.PatchEntity(id, request); await _webhookPublisher.PublishAsync("Agents.AgentUpdated", existingAgent.Id.ToString(), existingAgent.Name).ConfigureAwait(false); return(result); } catch (Exception ex) { return(ex.GetActionResult()); } }