/// <summary> /// Updates a business event entity /// </summary> /// <param name="id"></param> /// <param name="request"></param> /// <returns></returns> public IntegrationEvent UpdateBusinessEvent(string id, CreateBusinessEventViewModel request) { Guid entityId = new Guid(id); var businessEvent = _integrationEventRepository.GetOne(entityId); if (businessEvent == null) { throw new EntityDoesNotExistException("No business event exists for the specified id"); } var namedIntegrationEvent = _integrationEventRepository.Find(null, d => d.Name.ToLower() == request.Name.ToLower() && d.Id != entityId)?.Items?.FirstOrDefault(); if (namedIntegrationEvent != null && namedIntegrationEvent.Id != entityId) { throw new EntityAlreadyExistsException("Business event already exists"); } businessEvent.Name = request.Name; businessEvent.Description = request.Description; businessEvent.EntityType = request.EntityType; businessEvent.PayloadSchema = request.PayloadSchema; businessEvent.Name = request.Name; return(businessEvent); }
public async Task <IActionResult> PatchBusinessEvent(string id, [FromBody] JsonPatchDocument <IntegrationEvent> request) { try { Guid entityId = new Guid(id); var existingEvent = _repository.GetOne(entityId); if (existingEvent == null) { throw new EntityDoesNotExistException($"IntegrationEvent with id {id} could not be found"); } if (existingEvent.IsSystem == true) { throw new UnauthorizedOperationException($"System events can't be updated", EntityOperationType.Update); } _integrationEventManager.AttemptPatchUpdate(request, id); return(await base.PatchEntity(id, request)); } catch (Exception ex) { return(ex.GetActionResult()); } }