diff --git a/src/core/DigitalData.TaskFlow.Application/Features/Workflows/Commands/CloseWorkflow/CloseWorkflowCommand.cs b/src/core/DigitalData.TaskFlow.Application/Features/Workflows/Commands/CloseWorkflow/CloseWorkflowCommand.cs index 47b669a..bc2e451 100644 --- a/src/core/DigitalData.TaskFlow.Application/Features/Workflows/Commands/CloseWorkflow/CloseWorkflowCommand.cs +++ b/src/core/DigitalData.TaskFlow.Application/Features/Workflows/Commands/CloseWorkflow/CloseWorkflowCommand.cs @@ -87,6 +87,11 @@ public sealed class CloseWorkflowCommandHandler(IWorkflowRepository workflowRepo /// Closing result envelope. public async Task> Handle(CloseWorkflowCommand request, CancellationToken cancellationToken) { + if (string.Equals(request.Source, "Contracts", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidRequestApiException("Quelle 'Contracts' wird fur Closing aktuell nicht unterstutzt"); + } + var decision = mapper.Map(request); var result = await workflowRepository.CloseAsync( diff --git a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/WorkflowRepository.cs b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/WorkflowRepository.cs index a27873c..2797f2a 100644 --- a/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/WorkflowRepository.cs +++ b/src/infrastructure/DigitalData.TaskFlow.Infrastructure/Repositories/WorkflowRepository.cs @@ -64,12 +64,12 @@ public sealed class WorkflowRepository(TaskFlowDbContext dbContext, IOptions ReadArray(JsonElement sourceElement, string propertyName) + private static IReadOnlyList ReadArray(JsonElement sourceElement, params string[] propertyNames) { - if (!sourceElement.TryGetProperty(propertyName, out var propertyElement) || propertyElement.ValueKind != JsonValueKind.Array) + foreach (var propertyName in propertyNames) { - return []; + if (!sourceElement.TryGetProperty(propertyName, out var propertyElement) + || propertyElement.ValueKind != JsonValueKind.Array) + { + continue; + } + + return propertyElement.EnumerateArray().Select(item => item.Clone()).ToList(); } - return propertyElement.EnumerateArray().Select(item => item.Clone()).ToList(); + return []; } }