diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/DeletePeerDID/DeletePeerDIDHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/DeletePeerDID/DeletePeerDIDHandler.cs index 987628b..4ba6a3d 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/DeletePeerDID/DeletePeerDIDHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/DeletePeerDID/DeletePeerDIDHandler.cs @@ -1,35 +1,33 @@ -using Blocktrust.CredentialWorkflow.Core.Entities.DIDComm; using FluentResults; using MediatR; using Microsoft.EntityFrameworkCore; -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.DeletePeerDID +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.DeletePeerDID; + +public class DeletePeerDIDHandler : IRequestHandler { - public class DeletePeerDIDHandler : IRequestHandler - { - private readonly DataContext _context; + private readonly DataContext _context; - public DeletePeerDIDHandler(DataContext context) - { - _context = context; - } + public DeletePeerDIDHandler(DataContext context) + { + _context = context; + } - public async Task Handle(DeletePeerDIDRequest request, CancellationToken cancellationToken) - { - _context.ChangeTracker.Clear(); + public async Task Handle(DeletePeerDIDRequest request, CancellationToken cancellationToken) + { + _context.ChangeTracker.Clear(); - var peerDIDEntity = await _context.PeerDIDEntities - .FirstOrDefaultAsync(p => p.PeerDIDEntityId == request.PeerDIDEntityId, cancellationToken); + var peerDIDEntity = await _context.PeerDIDEntities + .FirstOrDefaultAsync(p => p.PeerDIDEntityId == request.PeerDIDEntityId, cancellationToken); - if (peerDIDEntity is null) - { - return Result.Fail("The PeerDID does not exist in the database. It cannot be deleted."); - } + if (peerDIDEntity is null) + { + return Result.Fail("The PeerDID does not exist in the database. It cannot be deleted."); + } - _context.PeerDIDEntities.Remove(peerDIDEntity); - await _context.SaveChangesAsync(cancellationToken); + _context.PeerDIDEntities.Remove(peerDIDEntity); + await _context.SaveChangesAsync(cancellationToken); - return Result.Ok(); - } + return Result.Ok(); } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/DeletePeerDID/DeletePeerDIDRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/DeletePeerDID/DeletePeerDIDRequest.cs index 6e8582a..ff4fb0e 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/DeletePeerDID/DeletePeerDIDRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/DeletePeerDID/DeletePeerDIDRequest.cs @@ -1,15 +1,14 @@ using FluentResults; using MediatR; -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.DeletePeerDID +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.DeletePeerDID; + +public class DeletePeerDIDRequest : IRequest { - public class DeletePeerDIDRequest : IRequest + public DeletePeerDIDRequest(Guid peerDIDEntityId) { - public DeletePeerDIDRequest(Guid peerDIDEntityId) - { - PeerDIDEntityId = peerDIDEntityId; - } - - public Guid PeerDIDEntityId { get; } + PeerDIDEntityId = peerDIDEntityId; } + + public Guid PeerDIDEntityId { get; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDSecrets/GetPeerDIDSecretsHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDSecrets/GetPeerDIDSecretsHandler.cs index 05a7f4b..89a7baf 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDSecrets/GetPeerDIDSecretsHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDSecrets/GetPeerDIDSecretsHandler.cs @@ -1,11 +1,11 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDSecrets; - using Blocktrust.Common.Models.DidDoc; using Blocktrust.Common.Models.Secrets; using FluentResults; using MediatR; using Microsoft.EntityFrameworkCore; +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDSecrets; + public class GetPeerDIDSecretsHandler : IRequestHandler>> { private readonly DataContext _context; @@ -17,7 +17,7 @@ public class GetPeerDIDSecretsHandler : IRequestHandler public GetPeerDIDSecretsHandler(DataContext context) { - this._context = context; + _context = context; } /// diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDSecrets/GetPeerDIDSecretsRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDSecrets/GetPeerDIDSecretsRequest.cs index 265d009..8a24d28 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDSecrets/GetPeerDIDSecretsRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDSecrets/GetPeerDIDSecretsRequest.cs @@ -1,9 +1,9 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDSecrets; - using Blocktrust.Common.Models.Secrets; using FluentResults; using MediatR; +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDSecrets; + public class GetPeerDIDSecretsRequest : IRequest>> { public List Kids { get; } diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDs/GetPeerDIDsHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDs/GetPeerDIDsHandler.cs index 219d759..c98c90c 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDs/GetPeerDIDsHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDs/GetPeerDIDsHandler.cs @@ -1,37 +1,34 @@ -using Blocktrust.CredentialWorkflow.Core.Entities.DIDComm; using FluentResults; using MediatR; using Microsoft.EntityFrameworkCore; -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDs -{ - using Domain.PeerDID; +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDs; - public class GetPeerDIDsHandler : IRequestHandler>> - { - private readonly DataContext _context; +using Domain.PeerDID; - public GetPeerDIDsHandler(DataContext context) - { - _context = context; - } +public class GetPeerDIDsHandler : IRequestHandler>> +{ + private readonly DataContext _context; - public async Task>> Handle(GetPeerDIDsRequest request, CancellationToken cancellationToken) - { - _context.ChangeTracker.Clear(); + public GetPeerDIDsHandler(DataContext context) + { + _context = context; + } - var peerDIDEntities = await _context.PeerDIDEntities - .Where(p => p.TenantEntityId == request.TenantId) - .ToListAsync(cancellationToken); + public async Task>> Handle(GetPeerDIDsRequest request, CancellationToken cancellationToken) + { + _context.ChangeTracker.Clear(); - // If none found, we can return an empty list as a success - if (peerDIDEntities is null || peerDIDEntities.Count == 0) - { - return Result.Ok(new List()); - } + var peerDIDEntities = await _context.PeerDIDEntities + .Where(p => p.TenantEntityId == request.TenantId) + .ToListAsync(cancellationToken); - var peerDIDs = peerDIDEntities.Select(p => p.ToModel()).ToList(); - return Result.Ok(peerDIDs); + if (peerDIDEntities is null || peerDIDEntities.Count == 0) + { + return Result.Ok(new List()); } + + var peerDIDs = peerDIDEntities.Select(p => p.ToModel()).ToList(); + return Result.Ok(peerDIDs); } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDs/GetPeerDIDsRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDs/GetPeerDIDsRequest.cs index 2db8ba9..1d56c0b 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDs/GetPeerDIDsRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDIDs/GetPeerDIDsRequest.cs @@ -1,17 +1,16 @@ using FluentResults; using MediatR; -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDs -{ - using Domain.PeerDID; +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDs; - public class GetPeerDIDsRequest : IRequest>> - { - public GetPeerDIDsRequest(Guid tenantId) - { - TenantId = tenantId; - } +using Domain.PeerDID; - public Guid TenantId { get; } +public class GetPeerDIDsRequest : IRequest>> +{ + public GetPeerDIDsRequest(Guid tenantId) + { + TenantId = tenantId; } + + public Guid TenantId { get; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDidById/GetPeerDidByIdHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDidById/GetPeerDidByIdHandler.cs index 733649e..335d6d1 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDidById/GetPeerDidByIdHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDidById/GetPeerDidByIdHandler.cs @@ -1,34 +1,32 @@ -using Blocktrust.CredentialWorkflow.Core.Entities.DIDComm; using FluentResults; using MediatR; using Microsoft.EntityFrameworkCore; -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDidById -{ - using Domain.PeerDID; +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDidById; - public class GetPeerDidByIdHandler : IRequestHandler> - { - private readonly DataContext _context; +using Domain.PeerDID; - public GetPeerDidByIdHandler(DataContext context) - { - _context = context; - } +public class GetPeerDidByIdHandler : IRequestHandler> +{ + private readonly DataContext _context; - public async Task> Handle(GetPeerDidByIdRequest request, CancellationToken cancellationToken) - { - _context.ChangeTracker.Clear(); + public GetPeerDidByIdHandler(DataContext context) + { + _context = context; + } - var peerDIDEntity = await _context.PeerDIDEntities - .FirstOrDefaultAsync(p => p.PeerDIDEntityId == request.PeerDidEntityId, cancellationToken); + public async Task> Handle(GetPeerDidByIdRequest request, CancellationToken cancellationToken) + { + _context.ChangeTracker.Clear(); - if (peerDIDEntity is null) - { - return Result.Fail($"PeerDID with ID '{request.PeerDidEntityId}' not found."); - } + var peerDIDEntity = await _context.PeerDIDEntities + .FirstOrDefaultAsync(p => p.PeerDIDEntityId == request.PeerDidEntityId, cancellationToken); - return Result.Ok(peerDIDEntity.ToModel()); + if (peerDIDEntity is null) + { + return Result.Fail($"PeerDID with ID '{request.PeerDidEntityId}' not found."); } + + return Result.Ok(peerDIDEntity.ToModel()); } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDidById/GetPeerDidByIdRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDidById/GetPeerDidByIdRequest.cs index b38ba79..a9205cc 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDidById/GetPeerDidByIdRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/GetPeerDidById/GetPeerDidByIdRequest.cs @@ -1,17 +1,16 @@ using FluentResults; using MediatR; -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDidById +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDidById; + +using Domain.PeerDID; + +public class GetPeerDidByIdRequest : IRequest> { - using Domain.PeerDID; + public Guid PeerDidEntityId { get; } - public class GetPeerDidByIdRequest : IRequest> + public GetPeerDidByIdRequest(Guid peerDidEntityId) { - public Guid PeerDidEntityId { get; } - - public GetPeerDidByIdRequest(Guid peerDidEntityId) - { - PeerDidEntityId = peerDidEntityId; - } + PeerDidEntityId = peerDidEntityId; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/SavePeerDID/SavePeerDIDHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/SavePeerDID/SavePeerDIDHandler.cs index a2eb31a..5a9dd68 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/SavePeerDID/SavePeerDIDHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/SavePeerDID/SavePeerDIDHandler.cs @@ -1,50 +1,49 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.SavePeerDID +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.SavePeerDID; + +using Blocktrust.CredentialWorkflow.Core.Entities.DIDComm; +using Domain.PeerDID; +using FluentResults; +using MediatR; +using Microsoft.EntityFrameworkCore; + +public class SavePeerDIDHandler : IRequestHandler> { - using Blocktrust.CredentialWorkflow.Core.Entities.DIDComm; - using Domain.PeerDID; - using FluentResults; - using MediatR; - using Microsoft.EntityFrameworkCore; + private readonly DataContext _context; - public class SavePeerDIDHandler : IRequestHandler> + public SavePeerDIDHandler(DataContext context) { - private readonly DataContext _context; + _context = context; + } - public SavePeerDIDHandler(DataContext context) + public async Task> Handle(SavePeerDIDRequest request, CancellationToken cancellationToken) + { + _context.ChangeTracker.Clear(); + _context.ChangeTracker.AutoDetectChangesEnabled = false; + + // Validate tenant + var tenant = await _context.TenantEntities + .FirstOrDefaultAsync(t => t.TenantEntityId == request.TenantId, cancellationToken); + + if (tenant is null) { - _context = context; + return Result.Fail("The tenant does not exist in the database. The PeerDID cannot be created."); } - public async Task> Handle(SavePeerDIDRequest request, CancellationToken cancellationToken) + // Create the new PeerDIDEntity + var peerDIDEntity = new PeerDIDEntity { - _context.ChangeTracker.Clear(); - _context.ChangeTracker.AutoDetectChangesEnabled = false; - - // Validate tenant - var tenant = await _context.TenantEntities - .FirstOrDefaultAsync(t => t.TenantEntityId == request.TenantId, cancellationToken); - - if (tenant is null) - { - return Result.Fail("The tenant does not exist in the database. The PeerDID cannot be created."); - } - - // Create the new PeerDIDEntity - var peerDIDEntity = new PeerDIDEntity - { - PeerDIDEntityId = Guid.NewGuid(), - Name = request.Name, - PeerDID = request.PeerDID, - TenantEntityId = tenant.TenantEntityId, - CreatedUtc = DateTime.UtcNow - }; - - // Insert and save - await _context.PeerDIDEntities.AddAsync(peerDIDEntity, cancellationToken); - await _context.SaveChangesAsync(cancellationToken); - - // Return the domain model - return Result.Ok(peerDIDEntity.ToModel()); - } + PeerDIDEntityId = Guid.NewGuid(), + Name = request.Name, + PeerDID = request.PeerDID, + TenantEntityId = tenant.TenantEntityId, + CreatedUtc = DateTime.UtcNow + }; + + // Insert and save + await _context.PeerDIDEntities.AddAsync(peerDIDEntity, cancellationToken); + await _context.SaveChangesAsync(cancellationToken); + + // Return the domain model + return Result.Ok(peerDIDEntity.ToModel()); } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/SavePeerDID/SavePeerDIDRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/SavePeerDID/SavePeerDIDRequest.cs index b13b261..4516387 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/SavePeerDID/SavePeerDIDRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/DIDComm/SavePeerDID/SavePeerDIDRequest.cs @@ -1,20 +1,19 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.SavePeerDID -{ - using Domain.PeerDID; - using FluentResults; - using MediatR; +namespace Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.SavePeerDID; - public class SavePeerDIDRequest : IRequest> - { - public SavePeerDIDRequest(Guid tenantId, string name, string peerDid) - { - TenantId = tenantId; - Name = name; - PeerDID = peerDid; - } +using Domain.PeerDID; +using FluentResults; +using MediatR; - public Guid TenantId { get; } - public string Name { get; } - public string PeerDID { get; } +public class SavePeerDIDRequest : IRequest> +{ + public SavePeerDIDRequest(Guid tenantId, string name, string peerDid) + { + TenantId = tenantId; + Name = name; + PeerDID = peerDid; } + + public Guid TenantId { get; } + public string Name { get; } + public string PeerDID { get; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/IssueCredentials/IssueW3cCredential/SignW3cCredential/SignW3cCredentialHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/IssueCredentials/IssueW3cCredential/SignW3cCredential/SignW3cCredentialHandler.cs index 74608c9..241f0ac 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/IssueCredentials/IssueW3cCredential/SignW3cCredential/SignW3cCredentialHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/IssueCredentials/IssueW3cCredential/SignW3cCredential/SignW3cCredentialHandler.cs @@ -1,13 +1,12 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.IssueCredentials.IssueW3cCredential.SignW3cCredential; - -using System.Text.Json; +using System.Text.Json; using System.Text.Json.Serialization; using Blocktrust.CredentialWorkflow.Core.Crypto; +using Blocktrust.CredentialWorkflow.Core.Domain.Credential; using Blocktrust.CredentialWorkflow.Core.Prism; -using Domain.Credential; using FluentResults; using MediatR; -using VerifiableCredential.Common.Converters; + +namespace Blocktrust.CredentialWorkflow.Core.Commands.IssueCredentials.IssueW3cCredential.SignW3cCredential; public class SignW3cCredentialHandler : IRequestHandler> { @@ -17,7 +16,6 @@ public class SignW3cCredentialHandler : IRequestHandler> Handle(SignW3cCredentialRequest request, Cance var headerJson = JsonSerializer.Serialize(header, SerializerOptions); var headerBase64 = PrismEncoding.ByteArrayToBase64(PrismEncoding.Utf8StringToByteArray(headerJson)); - Credential cleanCredential = new Credential() + Credential cleanCredential = new Credential { CredentialContext = request.Credential.CredentialContext, Type = request.Credential.Type, diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/IssueCredentials/IssueW3cCredential/SignW3cCredential/SignW3cCredentialRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/IssueCredentials/IssueW3cCredential/SignW3cCredential/SignW3cCredentialRequest.cs index b5c22f8..2bec855 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/IssueCredentials/IssueW3cCredential/SignW3cCredential/SignW3cCredentialRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/IssueCredentials/IssueW3cCredential/SignW3cCredential/SignW3cCredentialRequest.cs @@ -1,9 +1,9 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.IssueCredentials.IssueW3cCredential.SignW3cCredential; - -using Blocktrust.CredentialWorkflow.Core.Domain.Credential; +using Blocktrust.CredentialWorkflow.Core.Domain.Credential; using FluentResults; using MediatR; +namespace Blocktrust.CredentialWorkflow.Core.Commands.IssueCredentials.IssueW3cCredential.SignW3cCredential; + public class SignW3cCredentialRequest : IRequest> { public SignW3cCredentialRequest(Credential credential, byte[] privateKey, string issuerDid) diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Tenant/GetPrivateIssuingKeyByDid/GetPrivateIssuingKeyByDidRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Tenant/GetPrivateIssuingKeyByDid/GetPrivateIssuingKeyByDidRequest.cs index 9203470..f8783a4 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Tenant/GetPrivateIssuingKeyByDid/GetPrivateIssuingKeyByDidRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Tenant/GetPrivateIssuingKeyByDid/GetPrivateIssuingKeyByDidRequest.cs @@ -1,15 +1,14 @@ using FluentResults; using MediatR; -namespace Blocktrust.CredentialWorkflow.Core.Commands.Tenant.GetPrivateIssuingKeyByDid +namespace Blocktrust.CredentialWorkflow.Core.Commands.Tenant.GetPrivateIssuingKeyByDid; + +public class GetPrivateIssuingKeyByDidRequest : IRequest> { - public class GetPrivateIssuingKeyByDidRequest : IRequest> - { - public string Did { get; } + public string Did { get; } - public GetPrivateIssuingKeyByDidRequest(string did) - { - Did = did; - } + public GetPrivateIssuingKeyByDidRequest(string did) + { + Did = did; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/ValidateCredentials/CustomValidation/CustomValidationHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/ValidateCredentials/CustomValidation/CustomValidationHandler.cs index 750f065..4626374 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/ValidateCredentials/CustomValidation/CustomValidationHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/ValidateCredentials/CustomValidation/CustomValidationHandler.cs @@ -31,7 +31,7 @@ public async Task> Handle(CustomValidationRequest { result.Errors.Add(new CustomValidationError( rule.Name, - rule.ErrorMessage ?? $"Validation rule '{rule.Name}' failed" + rule.ErrorMessage )); } } diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ChangeWorkflowState/ChangeWorkflowStateHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ChangeWorkflowState/ChangeWorkflowStateHandler.cs index c50edfb..99415cb 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ChangeWorkflowState/ChangeWorkflowStateHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ChangeWorkflowState/ChangeWorkflowStateHandler.cs @@ -1,46 +1,45 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ChangeWorkflowState +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ChangeWorkflowState; + +using System; +using System.Threading; +using System.Threading.Tasks; +using Domain.Enums; +using Domain.Workflow; +using FluentResults; +using MediatR; +using Microsoft.EntityFrameworkCore; + +public class ChangeWorkflowStateHandler : IRequestHandler> { - using System; - using System.Threading; - using System.Threading.Tasks; - using Domain.Enums; - using Domain.Workflow; - using FluentResults; - using MediatR; - using Microsoft.EntityFrameworkCore; - - public class ChangeWorkflowStateHandler : IRequestHandler> + private readonly DataContext _context; + + public ChangeWorkflowStateHandler(DataContext context) { - private readonly DataContext _context; + _context = context; + } + + public async Task> Handle(ChangeWorkflowStateRequest request, CancellationToken cancellationToken) + { + _context.ChangeTracker.Clear(); + + var workflow = await _context.WorkflowEntities + .FirstOrDefaultAsync(w => w.WorkflowEntityId == request.WorkflowId, cancellationToken); - public ChangeWorkflowStateHandler(DataContext context) + if (workflow is null) { - _context = context; + return Result.Fail("The workflow does not exist in the database. It cannot change its state."); } - public async Task> Handle(ChangeWorkflowStateRequest request, CancellationToken cancellationToken) + workflow.WorkflowState = request.WorkflowState; + workflow.UpdatedUtc = DateTime.UtcNow; + if (workflow.WorkflowState != EWorkflowState.Inactive) { - _context.ChangeTracker.Clear(); - - var workflow = await _context.WorkflowEntities - .FirstOrDefaultAsync(w => w.WorkflowEntityId == request.WorkflowId, cancellationToken); - - if (workflow is null) - { - return Result.Fail("The workflow does not exist in the database. It cannot change its state."); - } - - workflow.WorkflowState = request.WorkflowState; - workflow.UpdatedUtc = DateTime.UtcNow; - if (workflow.WorkflowState != EWorkflowState.Inactive) - { - workflow.IsRunable = true; - } + workflow.IsRunable = true; + } - _context.WorkflowEntities.Update(workflow); - await _context.SaveChangesAsync(cancellationToken); + _context.WorkflowEntities.Update(workflow); + await _context.SaveChangesAsync(cancellationToken); - return Result.Ok(workflow.Map()); - } + return Result.Ok(workflow.Map()); } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ChangeWorkflowState/ChangeWorkflowStateRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ChangeWorkflowState/ChangeWorkflowStateRequest.cs index 9d23e58..bcb6aad 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ChangeWorkflowState/ChangeWorkflowStateRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ChangeWorkflowState/ChangeWorkflowStateRequest.cs @@ -1,20 +1,19 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ChangeWorkflowState -{ - using System; - using FluentResults; - using MediatR; - using Domain.Enums; - using Domain.Workflow; +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ChangeWorkflowState; - public class ChangeWorkflowStateRequest : IRequest> - { - public ChangeWorkflowStateRequest(Guid workflowId, EWorkflowState workflowState) - { - WorkflowId = workflowId; - WorkflowState = workflowState; - } +using System; +using FluentResults; +using MediatR; +using Domain.Enums; +using Domain.Workflow; - public Guid WorkflowId { get; } - public EWorkflowState WorkflowState { get; } +public class ChangeWorkflowStateRequest : IRequest> +{ + public ChangeWorkflowStateRequest(Guid workflowId, EWorkflowState workflowState) + { + WorkflowId = workflowId; + WorkflowState = workflowState; } + + public Guid WorkflowId { get; } + public EWorkflowState WorkflowState { get; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/CustomValidationProcessor.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/CustomValidationProcessor.cs index 6074be7..f052eeb 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/CustomValidationProcessor.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/CustomValidationProcessor.cs @@ -1,12 +1,12 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; - using System.Text.Json; -using System.Threading.Tasks; using Blocktrust.CredentialWorkflow.Core.Commands.ValidateCredentials.CustomValidation; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Validation; using FluentResults; using MediatR; +using Action = Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Action; + +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; public class CustomValidationProcessor : IActionProcessor { diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/DIDCommActionProcessor.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/DIDCommActionProcessor.cs index 9b0c838..1f597f9 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/DIDCommActionProcessor.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/DIDCommActionProcessor.cs @@ -1,5 +1,3 @@ -using Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDs; -using Blocktrust.CredentialWorkflow.Core.Domain.Enums; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Outgoing; using Blocktrust.DIDComm.Message.Attachments; @@ -12,11 +10,7 @@ using Blocktrust.PeerDID.Types; using FluentResults; using MediatR; -using System; -using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/EmailActionProcessor.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/EmailActionProcessor.cs index 54676c6..5280378 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/EmailActionProcessor.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/EmailActionProcessor.cs @@ -1,15 +1,14 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; - -using System; -using System.Collections.Generic; using System.Text.RegularExpressions; -using System.Threading.Tasks; using Blocktrust.CredentialWorkflow.Core.Commands.Workflow.SendEmailAction; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Outgoing; using FluentResults; using MediatR; -using Action = Domain.ProcessFlow.Actions.Action; +using Action = Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Action; + +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; + +using Action = Action; public class EmailActionProcessor : IActionProcessor { diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/IssueW3CCredentialProcessor.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/IssueW3CCredentialProcessor.cs index 4b4fd2a..f0fd573 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/IssueW3CCredentialProcessor.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/IssueW3CCredentialProcessor.cs @@ -1,16 +1,16 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; - -using System; -using System.Threading.Tasks; +using Blocktrust.Common.Converter; using Blocktrust.CredentialWorkflow.Core.Commands.IssueCredentials.IssueW3cCredential.CreateW3cCredential; using Blocktrust.CredentialWorkflow.Core.Commands.IssueCredentials.IssueW3cCredential.SignW3cCredential; using Blocktrust.CredentialWorkflow.Core.Commands.Tenant.GetPrivateIssuingKeyByDid; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Issuance; -using Common.Converter; using FluentResults; using MediatR; -using Action = Domain.ProcessFlow.Actions.Action; +using Action = Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Action; + +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; + +using Action = Action; public class IssueW3CCredentialProcessor : IActionProcessor { diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/VerifyW3CCredentialProcessor.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/VerifyW3CCredentialProcessor.cs index 1150e65..c5ec72b 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/VerifyW3CCredentialProcessor.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/VerifyW3CCredentialProcessor.cs @@ -1,12 +1,13 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; - -using System.Threading.Tasks; using Blocktrust.CredentialWorkflow.Core.Commands.VerifyCredentials.VerifyW3cCredentials.VerifyW3cCredential; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Verification; using FluentResults; using MediatR; -using Action = Domain.ProcessFlow.Actions.Action; +using Action = Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Action; + +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; + +using Action = Action; public class VerifyW3CCredentialProcessor : IActionProcessor { diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/W3cValidationProcessor.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/W3cValidationProcessor.cs index 883af58..825aacc 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/W3cValidationProcessor.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ActionProcessors/W3cValidationProcessor.cs @@ -1,12 +1,12 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; - using System.Text.Json; -using System.Threading.Tasks; using Blocktrust.CredentialWorkflow.Core.Commands.ValidateCredentials.W3cValidation; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Validation; using FluentResults; using MediatR; +using Action = Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Action; + +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; public class W3cValidationProcessor : IActionProcessor { diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ExecuteWorkflowHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ExecuteWorkflowHandler.cs index 9042b52..69b7e2f 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ExecuteWorkflowHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ExecuteWorkflowHandler.cs @@ -1,16 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; using Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow.ActionProcessors; using Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcome; -using Blocktrust.CredentialWorkflow.Core.Domain.Common; using Blocktrust.CredentialWorkflow.Core.Domain.Enums; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Triggers; -using Blocktrust.Mediator.Common.Protocols; using FluentResults; using MediatR; using Microsoft.Extensions.DependencyInjection; diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ExecuteWorkflowRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ExecuteWorkflowRequest.cs index b27ffdd..a58d04e 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ExecuteWorkflowRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ExecuteWorkflowRequest.cs @@ -1,9 +1,6 @@ namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow; -using Domain.Common; -using Domain.ProcessFlow.Actions; using Domain.Workflow; -using Entities.Outcome; using FluentResults; using MediatR; diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/IActionProcessor.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/IActionProcessor.cs index b807a76..c505565 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/IActionProcessor.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/IActionProcessor.cs @@ -1,7 +1,5 @@ -using Blocktrust.CredentialWorkflow.Core.Domain.Enums; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using FluentResults; -using System.Threading.Tasks; namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow; diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ParameterResolver.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ParameterResolver.cs index 6be33de..e259108 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ParameterResolver.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/ExecuteWorkflow/ParameterResolver.cs @@ -1,15 +1,13 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDs; using Blocktrust.CredentialWorkflow.Core.Commands.Tenant.GetIssuingKeys; using Blocktrust.CredentialWorkflow.Core.Domain.Common; using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using MediatR; -using ExecutionContext = Domain.Common.ExecutionContext; +using ExecutionContext = Blocktrust.CredentialWorkflow.Core.Domain.Common.ExecutionContext; + +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.ExecuteWorkflow; + +using ExecutionContext = ExecutionContext; public static class ParameterResolver { diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetActiveRecurringWorkflows/GetActiveRecurringWorkflowsHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetActiveRecurringWorkflows/GetActiveRecurringWorkflowsHandler.cs index 84019a4..3a3781e 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetActiveRecurringWorkflows/GetActiveRecurringWorkflowsHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetActiveRecurringWorkflows/GetActiveRecurringWorkflowsHandler.cs @@ -1,71 +1,65 @@ -using Blocktrust.CredentialWorkflow.Core.Entities.Workflow; using Blocktrust.CredentialWorkflow.Core.Domain.Enums; using FluentResults; using MediatR; using Microsoft.EntityFrameworkCore; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.GetActiveRecurringWorkflows +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.GetActiveRecurringWorkflows; + +using Domain.ProcessFlow; +using Domain.ProcessFlow.Triggers; +using Domain.Workflow; + +public class GetActiveRecurringWorkflowsHandler : IRequestHandler>> { - using Domain.ProcessFlow; - using Domain.ProcessFlow.Triggers; - using Domain.Workflow; + private readonly DataContext _context; - public class GetActiveRecurringWorkflowsHandler : IRequestHandler>> + public GetActiveRecurringWorkflowsHandler(DataContext context) { - private readonly DataContext _context; + _context = context; + } - public GetActiveRecurringWorkflowsHandler(DataContext context) - { - _context = context; - } + public async Task>> Handle(GetActiveRecurringWorkflowsRequest request, CancellationToken cancellationToken) + { + // Query all workflows that are active with recurrent triggers. + var workflows = await _context.WorkflowEntities + .Where(w => w.WorkflowState == EWorkflowState.ActiveWithRecurrentTrigger && w.ProcessFlowJson != null) + .ToListAsync(cancellationToken); - public async Task>> Handle(GetActiveRecurringWorkflowsRequest request, CancellationToken cancellationToken) + if (!workflows.Any()) { - // Query all workflows that are active with recurrent triggers. - var workflows = await _context.WorkflowEntities - .Where(w => w.WorkflowState == EWorkflowState.ActiveWithRecurrentTrigger && w.ProcessFlowJson != null) - .ToListAsync(cancellationToken); + return Result.Ok(new List()); + } - if (!workflows.Any()) + var activeRecurringWorkflows = workflows.Select(w => new ActiveRecurringWorkflow { - return Result.Ok(new List()); - } - - var activeRecurringWorkflows = workflows.Select(w => new ActiveRecurringWorkflow - { - WorkflowEntityId = w.WorkflowEntityId, - WorkflowState = w.WorkflowState, - UpdatedUtc = w.UpdatedUtc, - CronExpression = ExtractCronExpression(w.ProcessFlowJson) - }).Where(p => !string.IsNullOrEmpty(p.CronExpression)) - .ToList(); + WorkflowEntityId = w.WorkflowEntityId, + WorkflowState = w.WorkflowState, + UpdatedUtc = w.UpdatedUtc, + CronExpression = ExtractCronExpression(w.ProcessFlowJson) + }).Where(p => !string.IsNullOrEmpty(p.CronExpression)) + .ToList(); - return Result.Ok(activeRecurringWorkflows); - } + return Result.Ok(activeRecurringWorkflows); + } - private string ExtractCronExpression(string? processFlowJson) + private string ExtractCronExpression(string? processFlowJson) + { + var stringValue = string.IsNullOrEmpty(processFlowJson) ? string.Empty : processFlowJson; + var processFlow = ProcessFlow.DeserializeFromJson(stringValue); + var trigger = processFlow.Triggers.First().Value; + if (trigger.Type == ETriggerType.RecurringTimer) { - var stringValue = string.IsNullOrEmpty(processFlowJson) ? string.Empty : processFlowJson; - var processFlow = ProcessFlow.DeserializeFromJson(stringValue); - var trigger = processFlow.Triggers.First().Value; - if (trigger.Type == ETriggerType.RecurringTimer) - { - var recurringTimer = (TriggerInputRecurringTimer)trigger.Input; - if (string.IsNullOrEmpty(recurringTimer.CronExpression)) - { - return string.Empty; - } - - return recurringTimer.CronExpression; - } - else + var recurringTimer = (TriggerInputRecurringTimer)trigger.Input; + if (string.IsNullOrEmpty(recurringTimer.CronExpression)) { return string.Empty; } + + return recurringTimer.CronExpression; + } + else + { + return string.Empty; } } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetActiveRecurringWorkflows/GetActiveRecurringWorkflowsRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetActiveRecurringWorkflows/GetActiveRecurringWorkflowsRequest.cs index 4974e47..9775ab2 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetActiveRecurringWorkflows/GetActiveRecurringWorkflowsRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetActiveRecurringWorkflows/GetActiveRecurringWorkflowsRequest.cs @@ -1,12 +1,10 @@ using FluentResults; using MediatR; -using System.Collections.Generic; -namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.GetActiveRecurringWorkflows -{ - using Domain.Workflow; +namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.GetActiveRecurringWorkflows; + +using Domain.Workflow; - public class GetActiveRecurringWorkflowsRequest : IRequest>> - { - } +public class GetActiveRecurringWorkflowsRequest : IRequest>> +{ } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetWorkflowById/GetWorkflowByIdRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetWorkflowById/GetWorkflowByIdRequest.cs index df9d2b7..0f565e5 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetWorkflowById/GetWorkflowByIdRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetWorkflowById/GetWorkflowByIdRequest.cs @@ -1,6 +1,5 @@ namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.GetWorkflowById; -using Blocktrust.CredentialWorkflow.Core.Entities.Workflow; using Domain.Workflow; using FluentResults; using MediatR; diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetWorkflowSummaries/GetWorkflowSummariesHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetWorkflowSummaries/GetWorkflowSummariesHandler.cs index 19d48be..31fa639 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetWorkflowSummaries/GetWorkflowSummariesHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/Workflow/GetWorkflowSummaries/GetWorkflowSummariesHandler.cs @@ -2,7 +2,6 @@ namespace Blocktrust.CredentialWorkflow.Core.Commands.Workflow.GetWorkflowSummar using Blocktrust.CredentialWorkflow.Core.Domain.Workflow; using FluentResults; -using GetWorkflows; using MediatR; using Microsoft.EntityFrameworkCore; diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/CreateWorkflowOutcome/CreateWorkflowOutcomeHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/CreateWorkflowOutcome/CreateWorkflowOutcomeHandler.cs index 5a430e2..b6617d9 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/CreateWorkflowOutcome/CreateWorkflowOutcomeHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/CreateWorkflowOutcome/CreateWorkflowOutcomeHandler.cs @@ -1,11 +1,11 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.CreateWorkflowOutcome; - using Blocktrust.CredentialWorkflow.Core.Domain.Enums; using Blocktrust.CredentialWorkflow.Core.Entities.Outcome; using FluentResults; using MediatR; using Microsoft.EntityFrameworkCore; +namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.CreateWorkflowOutcome; + public class CreateWorkflowOutcomeHandler : IRequestHandler> { private readonly DataContext _context; @@ -27,7 +27,7 @@ public async Task> Handle(CreateWorkflowOutcomeRequest request, Can return Result.Fail("The workflow does not exist in the database. The outcome cannot be created."); } - var outcomeEntity = new WorkflowOutcomeEntity() + var outcomeEntity = new WorkflowOutcomeEntity { WorkflowOutcomeState = EWorkflowOutcomeState.NotStarted, WorkflowEntityId = workflow.WorkflowEntityId, diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeById/GetWorkflowOutcomeByIdRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeById/GetWorkflowOutcomeByIdRequest.cs index ab4dfa0..56ee913 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeById/GetWorkflowOutcomeByIdRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeById/GetWorkflowOutcomeByIdRequest.cs @@ -1,6 +1,5 @@ namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.GetWorkflowOutcomeById; -using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; using Domain.Workflow; using FluentResults; using MediatR; diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeIdsByState/GetWorkflowOutcomeIdsByStateRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeIdsByState/GetWorkflowOutcomeIdsByStateRequest.cs index b83dd9a..418300b 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeIdsByState/GetWorkflowOutcomeIdsByStateRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeIdsByState/GetWorkflowOutcomeIdsByStateRequest.cs @@ -1,16 +1,15 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.GetWorkflowOutcomeIdsByState -{ - using Blocktrust.CredentialWorkflow.Core.Domain.Enums; - using FluentResults; - using MediatR; +namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.GetWorkflowOutcomeIdsByState; - public class GetWorkflowOutcomeIdsByStateRequest : IRequest>> - { - public GetWorkflowOutcomeIdsByStateRequest(IEnumerable outcomeStates) - { - WorkflowOutcomeStates = outcomeStates?.ToList() ?? new List(); - } +using Blocktrust.CredentialWorkflow.Core.Domain.Enums; +using FluentResults; +using MediatR; - public List WorkflowOutcomeStates { get; } +public class GetWorkflowOutcomeIdsByStateRequest : IRequest>> +{ + public GetWorkflowOutcomeIdsByStateRequest(IEnumerable outcomeStates) + { + WorkflowOutcomeStates = outcomeStates?.ToList() ?? new List(); } + + public List WorkflowOutcomeStates { get; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeIdsByState/GetWorkflowOutcomeIdsByStateResponse.cs b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeIdsByState/GetWorkflowOutcomeIdsByStateResponse.cs index e563172..00d0d1b 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeIdsByState/GetWorkflowOutcomeIdsByStateResponse.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/GetWorkflowOutcomeIdsByState/GetWorkflowOutcomeIdsByStateResponse.cs @@ -1,10 +1,9 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.GetWorkflowOutcomeIdsByState -{ - using Blocktrust.CredentialWorkflow.Core.Domain.Enums; +namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.GetWorkflowOutcomeIdsByState; + +using Domain.Enums; - public class GetWorkflowOutcomeIdsByStateResponse - { - public Guid OutcomeId { get; set; } - public EWorkflowOutcomeState WorkflowOutcomeState { get; set; } - } +public class GetWorkflowOutcomeIdsByStateResponse +{ + public Guid OutcomeId { get; set; } + public EWorkflowOutcomeState WorkflowOutcomeState { get; set; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcome/UpdateWorkflowOutcomeHandler.cs b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcome/UpdateWorkflowOutcomeHandler.cs index cfc2565..279eeb8 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcome/UpdateWorkflowOutcomeHandler.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcome/UpdateWorkflowOutcomeHandler.cs @@ -1,13 +1,11 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcome; - using Blocktrust.CredentialWorkflow.Core.Domain.Enums; -using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; -using Domain.Workflow; using FluentResults; using MediatR; using Microsoft.EntityFrameworkCore; -public class UpdateWorkflowOutcomeHandler : IRequestHandler> +namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcome; + +public class UpdateWorkflowOutcomeHandler : IRequestHandler> { private readonly DataContext _context; @@ -16,7 +14,7 @@ public UpdateWorkflowOutcomeHandler(DataContext context) _context = context; } - public async Task> Handle(UpdateWorkflowOutcomeRequest request, CancellationToken cancellationToken) + public async Task> Handle(UpdateWorkflowOutcomeRequest request, CancellationToken cancellationToken) { _context.ChangeTracker.Clear(); var outcomeEntity = await _context.WorkflowOutcomeEntities @@ -24,7 +22,7 @@ public async Task> Handle(UpdateWorkflowOutcomeRequest r if (outcomeEntity is null) { - return Result.Fail("The outcome does not exist in the database. The outcome cannot be updated."); + return Result.Fail("The outcome does not exist in the database. The outcome cannot be updated."); } outcomeEntity.WorkflowOutcomeState = request.WorkflowOutcomeState; diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcome/UpdateWorkflowOutcomeRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcome/UpdateWorkflowOutcomeRequest.cs index e3dae3d..c8cb388 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcome/UpdateWorkflowOutcomeRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcome/UpdateWorkflowOutcomeRequest.cs @@ -1,11 +1,10 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcome; - using Blocktrust.CredentialWorkflow.Core.Domain.Enums; -using Domain.Workflow; using FluentResults; using MediatR; -public class UpdateWorkflowOutcomeRequest : IRequest> +namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcome; + +public class UpdateWorkflowOutcomeRequest : IRequest> { public UpdateWorkflowOutcomeRequest(Guid workflowOutcomeId, EWorkflowOutcomeState workflowOutcomeState, string? outcomeJson, string? errorMessage) { diff --git a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcomeState/UpdateWorkflowOutcomeStateRequest.cs b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcomeState/UpdateWorkflowOutcomeStateRequest.cs index f02552f..4de09ad 100644 --- a/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcomeState/UpdateWorkflowOutcomeStateRequest.cs +++ b/Blocktrust.CredentialWorkflow.Core/Commands/WorkflowOutcome/UpdateWorkflowOutcomeState/UpdateWorkflowOutcomeStateRequest.cs @@ -1,18 +1,17 @@ -namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcomeState -{ - using Blocktrust.CredentialWorkflow.Core.Domain.Enums; - using FluentResults; - using MediatR; +using Blocktrust.CredentialWorkflow.Core.Domain.Enums; +using FluentResults; +using MediatR; - public class UpdateWorkflowOutcomeStateRequest : IRequest - { - public UpdateWorkflowOutcomeStateRequest(Guid workflowOutcomeId, EWorkflowOutcomeState newState) - { - WorkflowOutcomeId = workflowOutcomeId; - NewState = newState; - } +namespace Blocktrust.CredentialWorkflow.Core.Commands.WorkflowOutcome.UpdateWorkflowOutcomeState; - public Guid WorkflowOutcomeId { get; } - public EWorkflowOutcomeState NewState { get; } +public class UpdateWorkflowOutcomeStateRequest : IRequest +{ + public UpdateWorkflowOutcomeStateRequest(Guid workflowOutcomeId, EWorkflowOutcomeState newState) + { + WorkflowOutcomeId = workflowOutcomeId; + NewState = newState; } + + public Guid WorkflowOutcomeId { get; } + public EWorkflowOutcomeState NewState { get; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Domain/Common/ExecutionContext.cs b/Blocktrust.CredentialWorkflow.Core/Domain/Common/ExecutionContext.cs index e88373e..72d03dc 100644 --- a/Blocktrust.CredentialWorkflow.Core/Domain/Common/ExecutionContext.cs +++ b/Blocktrust.CredentialWorkflow.Core/Domain/Common/ExecutionContext.cs @@ -1,119 +1,116 @@ -using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.Text.Json; -namespace Blocktrust.CredentialWorkflow.Core.Domain.Common +namespace Blocktrust.CredentialWorkflow.Core.Domain.Common; + +/// +/// Represents an execution context that combines parameters from the HTTP query string and request body. +/// Query parameters have precedence over body parameters when keys conflict. +/// +public class ExecutionContext { /// - /// Represents an execution context that combines parameters from the HTTP query string and request body. - /// Query parameters have precedence over body parameters when keys conflict. + /// Gets the combined input parameters from the query string and request body. /// - public class ExecutionContext + public IReadOnlyDictionary? InputContext { get; } + + public Guid TenantId { get; set; } + + // Private constructor forces usage of the static factory method. + internal ExecutionContext(Guid tenantId, IReadOnlyDictionary? inputContext = null) { - /// - /// Gets the combined input parameters from the query string and request body. - /// - public IReadOnlyDictionary? InputContext { get; } + TenantId = tenantId; + InputContext = inputContext; + } - public Guid TenantId { get; set; } + public static ExecutionContext FromSimplifiedHttpContext(Guid tenantId, string context) + { + if (string.IsNullOrWhiteSpace(context)) + { + throw new ArgumentException("Context cannot be null or empty.", nameof(context)); + } - // Private constructor forces usage of the static factory method. - internal ExecutionContext(Guid tenantId, IReadOnlyDictionary? inputContext = null) + SimplifiedHttpContext simplifiedHttpContext; + try + { + simplifiedHttpContext = SimplifiedHttpContext.FromJson(context); + } + catch (JsonException ex) { - TenantId = tenantId; - InputContext = inputContext; + throw new ArgumentException("Invalid JSON provided for SimplifiedHttpContext.", nameof(context), ex); } - public static ExecutionContext FromSimplifiedHttpContext(Guid tenantId, string context) + if (simplifiedHttpContext == null) { - if (string.IsNullOrWhiteSpace(context)) - { - throw new ArgumentException("Context cannot be null or empty.", nameof(context)); - } + throw new InvalidOperationException("SimplifiedHttpContext could not be deserialized."); + } + + // Start with query parameters. These have precedence over body parameters. + var mergedParameters = new Dictionary(simplifiedHttpContext.QueryParameters.Select((x) => new KeyValuePair(x.Key.ToLowerInvariant().Trim(), x.Value))); - SimplifiedHttpContext simplifiedHttpContext; + // If a body is provided, merge its parameters. + if (!string.IsNullOrWhiteSpace(simplifiedHttpContext.Body)) + { + Dictionary? bodyParameters = null; try { - simplifiedHttpContext = SimplifiedHttpContext.FromJson(context); + bodyParameters = JsonSerializer.Deserialize>(simplifiedHttpContext.Body); } catch (JsonException ex) { - throw new ArgumentException("Invalid JSON provided for SimplifiedHttpContext.", nameof(context), ex); - } - - if (simplifiedHttpContext == null) - { - throw new InvalidOperationException("SimplifiedHttpContext could not be deserialized."); + throw new InvalidOperationException("Failed to parse body JSON.", ex); } - // Start with query parameters. These have precedence over body parameters. - var mergedParameters = new Dictionary(simplifiedHttpContext.QueryParameters.Select((x) => new KeyValuePair(x.Key.ToLowerInvariant().Trim(), x.Value))); - - // If a body is provided, merge its parameters. - if (!string.IsNullOrWhiteSpace(simplifiedHttpContext.Body)) + if (bodyParameters != null) { - Dictionary? bodyParameters = null; - try + // Use TryAdd so that existing query parameters (already in the dictionary) are not overwritten. + foreach (var bodyParam in bodyParameters) { - bodyParameters = JsonSerializer.Deserialize>(simplifiedHttpContext.Body); - } - catch (JsonException ex) - { - throw new InvalidOperationException("Failed to parse body JSON.", ex); - } - - if (bodyParameters != null) - { - // Use TryAdd so that existing query parameters (already in the dictionary) are not overwritten. - foreach (var bodyParam in bodyParameters) - { - mergedParameters.TryAdd(bodyParam.Key.ToLowerInvariant().Trim(), bodyParam.Value); - } + mergedParameters.TryAdd(bodyParam.Key.ToLowerInvariant().Trim(), bodyParam.Value); } } - - return new ExecutionContext(tenantId, new ReadOnlyDictionary(mergedParameters)); } - public static ExecutionContext FromForm(Guid tenantId, string context) + return new ExecutionContext(tenantId, new ReadOnlyDictionary(mergedParameters)); + } + + public static ExecutionContext FromForm(Guid tenantId, string context) + { + if (string.IsNullOrWhiteSpace(context)) { - if (string.IsNullOrWhiteSpace(context)) - { - throw new ArgumentException("Context cannot be null or empty.", nameof(context)); - } + throw new ArgumentException("Context cannot be null or empty.", nameof(context)); + } - try + try + { + using var jsonDoc = JsonDocument.Parse(context); + var root = jsonDoc.RootElement; + if (root.TryGetProperty("Data", out var dataElement) && dataElement.ValueKind == JsonValueKind.Object) { - using var jsonDoc = JsonDocument.Parse(context); - var root = jsonDoc.RootElement; - if (root.TryGetProperty("Data", out var dataElement) && dataElement.ValueKind == JsonValueKind.Object) + var parameters = new Dictionary(); + foreach (var property in dataElement.EnumerateObject()) { - var parameters = new Dictionary(); - foreach (var property in dataElement.EnumerateObject()) + string key = property.Name.ToLowerInvariant().Trim(); + if (property.Value.ValueKind == JsonValueKind.String) { - string key = property.Name.ToLowerInvariant().Trim(); - if (property.Value.ValueKind == JsonValueKind.String) - { - string value = property.Value.GetString(); - parameters[key] = value; - } - else - { - throw new InvalidOperationException($"Non-string value for key '{property.Name}' in FormSubmission data."); - } + string value = property.Value.GetString(); + parameters[key] = value; + } + else + { + throw new InvalidOperationException($"Non-string value for key '{property.Name}' in FormSubmission data."); } - return new ExecutionContext(tenantId, new ReadOnlyDictionary(parameters)); - } - else - { - throw new InvalidOperationException("FormSubmission data is missing or invalid."); } + return new ExecutionContext(tenantId, new ReadOnlyDictionary(parameters)); } - catch (JsonException ex) + else { - throw new ArgumentException("Invalid JSON provided for FormSubmission.", nameof(context), ex); + throw new InvalidOperationException("FormSubmission data is missing or invalid."); } } + catch (JsonException ex) + { + throw new ArgumentException("Invalid JSON provided for FormSubmission.", nameof(context), ex); + } } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Domain/Credential/Credential.cs b/Blocktrust.CredentialWorkflow.Core/Domain/Credential/Credential.cs index 7b496dc..7e69c8d 100644 --- a/Blocktrust.CredentialWorkflow.Core/Domain/Credential/Credential.cs +++ b/Blocktrust.CredentialWorkflow.Core/Domain/Credential/Credential.cs @@ -14,7 +14,7 @@ public Credential() // Constructor that takes base class public Credential(VerifiableCredential.VerifiableCredential baseCredential) { - // Copy all properties from base credential + // properties from base credential CredentialContext = baseCredential.CredentialContext; Type = baseCredential.Type; CredentialSubjects = baseCredential.CredentialSubjects; @@ -33,7 +33,7 @@ public Credential(VerifiableCredential.VerifiableCredential baseCredential) AdditionalData = baseCredential.AdditionalData; JwtParsingArtefact = baseCredential.JwtParsingArtefact; SerializationOption = baseCredential.SerializationOption; - // Note: copying read-only fields where needed + // copying read-only fields where needed DataModelType = baseCredential.DataModelType; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/ActionOutcome.cs b/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/ActionOutcome.cs index eb07d57..dd9cf8f 100644 --- a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/ActionOutcome.cs +++ b/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/ActionOutcome.cs @@ -1,7 +1,5 @@ namespace Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions; -using Blocktrust.CredentialWorkflow.Core.Domain.Enums; - public class ActionOutcome { public ActionOutcome(Guid actionId) diff --git a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Outgoing/OutgoingActions.cs b/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Outgoing/OutgoingActions.cs deleted file mode 100644 index dacecfe..0000000 --- a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Outgoing/OutgoingActions.cs +++ /dev/null @@ -1,52 +0,0 @@ -// using System.Text.Json.Serialization; -// using Blocktrust.CredentialWorkflow.Core.Domain.Common; -// -// namespace Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions.Outgoing; -// -// public class DIDCommAction : ActionInput -// { -// [JsonPropertyName("type")] -// public EDIDCommType Type { get; set; } -// -// [JsonPropertyName("peerDid")] -// public ParameterReference PeerDid { get; set; } = new(); -// -// [JsonPropertyName("message")] -// public Dictionary MessageContent { get; set; } = new(); -// } -// -// public enum EDIDCommType -// { -// TrustPing, -// Message -// } -// -// public class HttpAction : ActionInput -// { -// [JsonPropertyName("method")] -// public string Method { get; set; } = "POST"; -// -// [JsonPropertyName("endpoint")] -// public ParameterReference Endpoint { get; set; } = new(); -// -// [JsonPropertyName("headers")] -// public Dictionary Headers { get; set; } = new(); -// -// [JsonPropertyName("body")] -// public Dictionary Body { get; set; } = new(); -// } - -// public class EmailAction : ActionInput -// { -// [JsonPropertyName("to")] -// public ParameterReference To { get; set; } = new(); -// -// [JsonPropertyName("subject")] -// public ParameterReference Subject { get; set; } = new(); -// -// [JsonPropertyName("body")] -// public ParameterReference Body { get; set; } = new(); -// -// [JsonPropertyName("attachments")] -// public List Attachments { get; set; } = new(); -// } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Verification/VerifyAnoncredCredential.cs b/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Verification/VerifyAnoncredCredential.cs index 83d497f..453bd30 100644 --- a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Verification/VerifyAnoncredCredential.cs +++ b/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Verification/VerifyAnoncredCredential.cs @@ -19,5 +19,5 @@ public class VerifyAnoncredCredential : ActionInput [JsonPropertyName("checkExpiry")] public bool CheckExpiry { get; set; } = true; - // Anoncred specific properties can be added later + // Anoncred specific properties } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Verification/VerifyW3cSdCredential.cs b/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Verification/VerifyW3cSdCredential.cs index 169ac2a..5138150 100644 --- a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Verification/VerifyW3cSdCredential.cs +++ b/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Actions/Verification/VerifyW3cSdCredential.cs @@ -19,5 +19,5 @@ public class VerifyW3cSdCredential : ActionInput [JsonPropertyName("checkExpiry")] public bool CheckExpiry { get; set; } = true; - // SD-VC specific properties can be added later + // SD-VC specific properties } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Triggers/TriggerInputForm.cs b/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Triggers/TriggerInputForm.cs deleted file mode 100644 index 88cb931..0000000 --- a/Blocktrust.CredentialWorkflow.Core/Domain/ProcessFlow/Triggers/TriggerInputForm.cs +++ /dev/null @@ -1,12 +0,0 @@ -// namespace Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Triggers; -// -// public class TriggerInputForm : TriggerInput -// { -// public TriggerInputForm() -// { -// Id = Guid.NewGuid(); -// Parameters = new Dictionary(); -// } -// -// public Dictionary Parameters { get; set; } -// } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Domain/Workflow/Workflow.cs b/Blocktrust.CredentialWorkflow.Core/Domain/Workflow/Workflow.cs index 602d0f0..13e97b7 100644 --- a/Blocktrust.CredentialWorkflow.Core/Domain/Workflow/Workflow.cs +++ b/Blocktrust.CredentialWorkflow.Core/Domain/Workflow/Workflow.cs @@ -1,10 +1,7 @@ -using Blocktrust.CredentialWorkflow.Core.Domain.Common; - -namespace Blocktrust.CredentialWorkflow.Core.Domain.Workflow; +namespace Blocktrust.CredentialWorkflow.Core.Domain.Workflow; using Enums; using ProcessFlow; -using ProcessFlow.Actions; using Tenant; public record Workflow diff --git a/Blocktrust.CredentialWorkflow.Core/Entities/DIDComm/PeerDIDEntity.cs b/Blocktrust.CredentialWorkflow.Core/Entities/DIDComm/PeerDIDEntity.cs index 2dd187b..640a76a 100644 --- a/Blocktrust.CredentialWorkflow.Core/Entities/DIDComm/PeerDIDEntity.cs +++ b/Blocktrust.CredentialWorkflow.Core/Entities/DIDComm/PeerDIDEntity.cs @@ -1,35 +1,34 @@ -namespace Blocktrust.CredentialWorkflow.Core.Entities.DIDComm -{ - using System.ComponentModel.DataAnnotations; - using Domain.PeerDID; - using Microsoft.EntityFrameworkCore; +namespace Blocktrust.CredentialWorkflow.Core.Entities.DIDComm; - public class PeerDIDEntity - { - public Guid PeerDIDEntityId { get; set; } +using System.ComponentModel.DataAnnotations; +using Domain.PeerDID; +using Microsoft.EntityFrameworkCore; - [Unicode(true)] - [MaxLength(200)] - public string Name { get; set; } +public class PeerDIDEntity +{ + public Guid PeerDIDEntityId { get; set; } - [Unicode(true)] - [MaxLength(5000)] - public string PeerDID { get; set; } + [Unicode(true)] + [MaxLength(200)] + public string Name { get; set; } - public Guid TenantEntityId { get; set; } - public DateTime CreatedUtc { get; init; } + [Unicode(true)] + [MaxLength(5000)] + public string PeerDID { get; set; } - // Map this entity to the domain model - public PeerDIDModel ToModel() + public Guid TenantEntityId { get; set; } + public DateTime CreatedUtc { get; init; } + + // Map this entity to the domain model + public PeerDIDModel ToModel() + { + return new PeerDIDModel { - return new PeerDIDModel - { - PeerDIDEntityId = PeerDIDEntityId, - Name = Name, - PeerDID = PeerDID, - TenantEntityId = TenantEntityId, - CreatedUtc = CreatedUtc - }; - } + PeerDIDEntityId = PeerDIDEntityId, + Name = Name, + PeerDID = PeerDID, + TenantEntityId = TenantEntityId, + CreatedUtc = CreatedUtc + }; } } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Entities/Identity/ApplicationUser.cs b/Blocktrust.CredentialWorkflow.Core/Entities/Identity/ApplicationUser.cs index adbf063..3c2a1d2 100644 --- a/Blocktrust.CredentialWorkflow.Core/Entities/Identity/ApplicationUser.cs +++ b/Blocktrust.CredentialWorkflow.Core/Entities/Identity/ApplicationUser.cs @@ -3,7 +3,6 @@ namespace Blocktrust.CredentialWorkflow.Core.Entities.Identity; using Microsoft.AspNetCore.Identity; using Tenant; - // Add profile data for application users by adding properties to the ApplicationUser class public class ApplicationUser : IdentityUser { [PersonalData] public string? SomeOtherData { get; set; } diff --git a/Blocktrust.CredentialWorkflow.Core/Entities/Outcome/WorkflowOutcomeEntity.cs b/Blocktrust.CredentialWorkflow.Core/Entities/Outcome/WorkflowOutcomeEntity.cs index 59cc43e..5443a92 100644 --- a/Blocktrust.CredentialWorkflow.Core/Entities/Outcome/WorkflowOutcomeEntity.cs +++ b/Blocktrust.CredentialWorkflow.Core/Entities/Outcome/WorkflowOutcomeEntity.cs @@ -1,10 +1,8 @@ -using Blocktrust.CredentialWorkflow.Core.Domain.Common; using Blocktrust.CredentialWorkflow.Core.Domain.Enums; using Blocktrust.CredentialWorkflow.Core.Entities.Workflow; namespace Blocktrust.CredentialWorkflow.Core.Entities.Outcome; -using Domain.ProcessFlow.Actions; using Domain.Workflow; public class WorkflowOutcomeEntity diff --git a/Blocktrust.CredentialWorkflow.Core/Samples/SampleGenerator.cs b/Blocktrust.CredentialWorkflow.Core/Samples/SampleGenerator.cs deleted file mode 100644 index b3ef2c3..0000000 --- a/Blocktrust.CredentialWorkflow.Core/Samples/SampleGenerator.cs +++ /dev/null @@ -1,143 +0,0 @@ -using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow; - -namespace Blocktrust.CredentialWorkflow.Core.Samples -{ - public class SampleGenerator - { - public static ProcessFlow GenerateSampleProcessFlow() - { - var triggerId = Guid.NewGuid(); - var issuanceActionId = Guid.NewGuid(); - var outgoingRequestActionId = Guid.NewGuid(); - - return new ProcessFlow - { - // Triggers = new Dictionary - // { - // { - // triggerId, - // new Triggers - // { - // Type = ETriggerType.IncomingRequest, - // Input = new TriggerInputIncomingRequest - // { - // Id = Guid.NewGuid(), - // Method = "POST", - // Uri = "https://api.blocktrust.dev/issue-credential", - // Body = new - // { - // subjectId = "did:example:123456789abcdefghi", - // credentialType = "VerifiableCredential", - // claims = new - // { - // name = "Alice Smith", - // dateOfBirth = "1990-05-15" - // } - // }, - // Headers = new Dictionary - // { - // { "Content-Type", "application/json" }, - // { "Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } - // } - // } - // } - // } - // }, - // Actions = new Dictionary - // { - // { - // issuanceActionId, - // new Actions - // { - // Type = EActionType.CredentialIssuance, - // Input = new IssueW3cCredentialInput - // { - // Id = Guid.NewGuid(), - // Subject = "did:example:123456789abcdefghi", - // Issuer = "did:example:issuer987654321", - // Claims = new Dictionary - // { - // { "name", "Alice Smith" }, - // { "dateOfBirth", "1990-05-15" }, - // { "credentialType", "IdentityCredential" } - // } - // }, - // RunAfter = new Dictionary> - // { - // { triggerId, new List { EFlowStatus.Succeeded } } - // } - // } - // }, - // { - // outgoingRequestActionId, - // new Actions - // { - // Type = EActionType.OutgoingRequest, - // Input = new ActionInputOutgoingRequest - // { - // Id = Guid.NewGuid(), - // Method = "POST", - // Uri = "https://example.com/receive-credential", - // Body = "{\"credential\": \"eyJhbGciOiJFZERTQS...\"}", - // Headers = new Dictionary - // { - // { "Content-Type", "application/json" }, - // { "X-API-Key", "your-api-key-here" } - // } - // }, - // RunAfter = new Dictionary> - // { - // { issuanceActionId, new List { EFlowStatus.Succeeded } } - // } - // } - // } - // }, - // Outputs = new Dictionary - // { - // { - // triggerId, - // new Output - // { - // Type = OutputType.Object, - // Id = Guid.NewGuid(), - // Value = new - // { - // status = "Succeeded", - // message = "Incoming request processed successfully" - // } - // } - // }, - // { - // issuanceActionId, - // new Output - // { - // Type = OutputType.Object, - // Id = Guid.NewGuid(), - // Value = new - // { - // status = "Succeeded", - // message = "Credential issued successfully", - // credentialId = "vc:example:123456789" - // } - // } - // }, - // { - // outgoingRequestActionId, - // new Output - // { - // Type = OutputType.Object, - // Id = Guid.NewGuid(), - // Value = new - // { - // status = "Succeeded", - // message = "Credential sent successfully", - // httpStatus = 200, - // responseBody = "{\"received\": true, \"message\": \"Credential stored successfully\"}" - // } - // } - // } - // } - }; - } - } -} \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Services/CredentialService.cs b/Blocktrust.CredentialWorkflow.Core/Services/CredentialService.cs deleted file mode 100644 index 72779fc..0000000 --- a/Blocktrust.CredentialWorkflow.Core/Services/CredentialService.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Blocktrust.CredentialWorkflow.Core.Services.Interfaces; -using FluentResults; -using Microsoft.Extensions.Logging; - -namespace Blocktrust.CredentialWorkflow.Core.Services; - -public class CredentialService : ICredentialService -{ - private readonly ILogger _logger; - - public CredentialService(ILogger logger) - { - _logger = logger; - } - - public async Task> IssueCredential(string subjectDid, string issuerDid, string claimsJson) - { - try - { - // TODO: Implement actual credential issuance - // 1. Validate DIDs - // 2. Parse and validate claims - // 3. Create and sign credential - return Result.Ok("mocked_credential_jwt"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Failed to issue credential"); - return Result.Fail("Failed to issue credential: " + ex.Message); - } - } -} \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Services/DIDComm/PeerDIDSecretResolver.cs b/Blocktrust.CredentialWorkflow.Core/Services/DIDComm/PeerDIDSecretResolver.cs index dcd3887..1d0e102 100644 --- a/Blocktrust.CredentialWorkflow.Core/Services/DIDComm/PeerDIDSecretResolver.cs +++ b/Blocktrust.CredentialWorkflow.Core/Services/DIDComm/PeerDIDSecretResolver.cs @@ -1,11 +1,11 @@ -namespace Blocktrust.CredentialWorkflow.Core.Services.DIDComm; - using Blocktrust.Common.Models.Secrets; using Blocktrust.Common.Resolver; -using Commands.DIDComm.GetPeerDIDSecrets; -using Commands.DIDComm.SavePeerDIDSecrets; +using Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.GetPeerDIDSecrets; +using Blocktrust.CredentialWorkflow.Core.Commands.DIDComm.SavePeerDIDSecrets; using MediatR; +namespace Blocktrust.CredentialWorkflow.Core.Services.DIDComm; + public class PeerDIDSecretResolver : ISecretResolver { private readonly IMediator _mediator; @@ -17,7 +17,7 @@ public PeerDIDSecretResolver(IMediator mediator) public async Task FindKey(string kid) { - var secretResults = await _mediator.Send(new GetPeerDIDSecretsRequest(new List() { kid })); + var secretResults = await _mediator.Send(new GetPeerDIDSecretsRequest(new List { kid })); if (secretResults.IsFailed) { return null; diff --git a/Blocktrust.CredentialWorkflow.Core/Services/DeliveryService.cs b/Blocktrust.CredentialWorkflow.Core/Services/DeliveryService.cs index f4cc1a5..ec4a6f1 100644 --- a/Blocktrust.CredentialWorkflow.Core/Services/DeliveryService.cs +++ b/Blocktrust.CredentialWorkflow.Core/Services/DeliveryService.cs @@ -1,47 +1,47 @@ -using Blocktrust.CredentialWorkflow.Core.Services.Interfaces; -using FluentResults; -using Microsoft.Extensions.Logging; - -namespace Blocktrust.CredentialWorkflow.Core.Services; - -public class DeliveryService : IDeliveryService -{ - private readonly ILogger _logger; - private readonly IDidResolutionService _didResolutionService; - - public DeliveryService( - ILogger logger, - IDidResolutionService didResolutionService) - { - _logger = logger; - _didResolutionService = didResolutionService; - } - - public async Task DeliverViaEmail(string email, string credential) - { - try - { - // TODO: Implement email delivery - return Result.Ok(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Failed to deliver credential via email"); - return Result.Fail("Failed to deliver via email: " + ex.Message); - } - } - - public async Task DeliverViaDIDComm(string peerDid, string credential) - { - try - { - // TODO: Implement DIDComm delivery - return Result.Ok(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Failed to deliver credential via DIDComm"); - return Result.Fail("Failed to deliver via DIDComm: " + ex.Message); - } - } -} \ No newline at end of file +// using Blocktrust.CredentialWorkflow.Core.Services.Interfaces; +// using FluentResults; +// using Microsoft.Extensions.Logging; +// +// namespace Blocktrust.CredentialWorkflow.Core.Services; +// +// public class DeliveryService : IDeliveryService +// { +// private readonly ILogger _logger; +// private readonly IDidResolutionService _didResolutionService; +// +// public DeliveryService( +// ILogger logger, +// IDidResolutionService didResolutionService) +// { +// _logger = logger; +// _didResolutionService = didResolutionService; +// } +// +// public async Task DeliverViaEmail(string email, string credential) +// { +// try +// { +// // TODO: Implement email delivery +// return Result.Ok(); +// } +// catch (Exception ex) +// { +// _logger.LogError(ex, "Failed to deliver credential via email"); +// return Result.Fail("Failed to deliver via email: " + ex.Message); +// } +// } +// +// public async Task DeliverViaDIDComm(string peerDid, string credential) +// { +// try +// { +// // TODO: Implement DIDComm delivery +// return Result.Ok(); +// } +// catch (Exception ex) +// { +// _logger.LogError(ex, "Failed to deliver credential via DIDComm"); +// return Result.Fail("Failed to deliver via DIDComm: " + ex.Message); +// } +// } +// } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Services/DidResolutionService.cs b/Blocktrust.CredentialWorkflow.Core/Services/DidResolutionService.cs index c6c5449..ab1abf3 100644 --- a/Blocktrust.CredentialWorkflow.Core/Services/DidResolutionService.cs +++ b/Blocktrust.CredentialWorkflow.Core/Services/DidResolutionService.cs @@ -1,30 +1,30 @@ -using Blocktrust.CredentialWorkflow.Core.Domain.Did; -using Blocktrust.CredentialWorkflow.Core.Services.Interfaces; -using FluentResults; -using Microsoft.Extensions.Logging; - -namespace Blocktrust.CredentialWorkflow.Core.Services; - -public class DidResolutionService : IDidResolutionService -{ - private readonly ILogger _logger; - - public DidResolutionService(ILogger logger) - { - _logger = logger; - } - - public async Task> ResolveDid(string did) - { - try - { - // TODO: Implement actual DID resolution - return Result.Ok(new DidDocument()); - } - catch (Exception ex) - { - _logger.LogError(ex, "Failed to resolve DID: {Did}", did); - return Result.Fail("Failed to resolve DID: " + ex.Message); - } - } -} \ No newline at end of file +// using Blocktrust.CredentialWorkflow.Core.Domain.Did; +// using Blocktrust.CredentialWorkflow.Core.Services.Interfaces; +// using FluentResults; +// using Microsoft.Extensions.Logging; +// +// namespace Blocktrust.CredentialWorkflow.Core.Services; +// +// public class DidResolutionService : IDidResolutionService +// { +// private readonly ILogger _logger; +// +// public DidResolutionService(ILogger logger) +// { +// _logger = logger; +// } +// +// public async Task> ResolveDid(string did) +// { +// try +// { +// // TODO: Implement actual DID resolution +// return Result.Ok(new DidDocument()); +// } +// catch (Exception ex) +// { +// _logger.LogError(ex, "Failed to resolve DID: {Did}", did); +// return Result.Fail("Failed to resolve DID: " + ex.Message); +// } +// } +// } \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Core/Services/Interfaces/ICredentialService.cs b/Blocktrust.CredentialWorkflow.Core/Services/Interfaces/ICredentialService.cs deleted file mode 100644 index 0315388..0000000 --- a/Blocktrust.CredentialWorkflow.Core/Services/Interfaces/ICredentialService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using FluentResults; - -namespace Blocktrust.CredentialWorkflow.Core.Services.Interfaces; - -public interface ICredentialService -{ - Task> IssueCredential(string subjectDid, string issuerDid, string claimsJson); -} \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Web/Blocktrust.CredentialWorkflow.Web.csproj b/Blocktrust.CredentialWorkflow.Web/Blocktrust.CredentialWorkflow.Web.csproj index df3cca2..f538589 100644 --- a/Blocktrust.CredentialWorkflow.Web/Blocktrust.CredentialWorkflow.Web.csproj +++ b/Blocktrust.CredentialWorkflow.Web/Blocktrust.CredentialWorkflow.Web.csproj @@ -50,6 +50,7 @@ <_ContentIncludedByDefault Remove="Components\Features\PropertyWindow\Outcome\WorkflowOutcomeComponent.razor" /> <_ContentIncludedByDefault Remove="Components\Layout\TopBarComponents\Breadcrumb.razor" /> <_ContentIncludedByDefault Remove="Components\Features\HttpEndpointInfo\HttpEndpointInfo.razor" /> + <_ContentIncludedByDefault Remove="Components\Features\Outcome\OutcomeActionComponent.razor" /> diff --git a/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Outgoing/DIDCommActionComponent.razor b/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Outgoing/DIDCommActionComponent.razor index 10916f5..872577d 100644 --- a/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Outgoing/DIDCommActionComponent.razor +++ b/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Outgoing/DIDCommActionComponent.razor @@ -202,10 +202,8 @@ [Parameter] public EventCallback OnChange { get; set; } [Parameter] public IEnumerable? TriggerParameters { get; set; } - // New: needed if referencing previous actions for "ActionOutcome" [Parameter] public IEnumerable? FlowItems { get; set; } - // Holds the list of PeerDIDs retrieved via GetPeerDIDsRequest private List PeerDIDs { get; set; } = new(); protected override async Task OnInitializedAsync() @@ -213,7 +211,6 @@ var tenant = AppStateService.Tenant; var tenantId = tenant.TenantId; - // Fetch the list of PeerDIDs for this tenant var result = await Mediator.Send(new GetPeerDIDsRequest(tenantId)); if (result.IsSuccess) { @@ -221,7 +218,7 @@ } else { - // Handle error if needed, e.g., show a toast or fallback + // Handle error if needed, e.g., a toast or fallback } } @@ -272,10 +269,9 @@ await OnChange.InvokeAsync(); } - // New: For the “CredentialIssuance” block private async Task OnCredentialSourceChanged() { - // Additional logic if necessary. For now, simply notify of changes. + // notify of changes. await OnValueChanged(); } @@ -284,7 +280,6 @@ if (Guid.TryParse(e.Value?.ToString(), out var guid)) { ActionInput.CredentialReference.ActionId = guid; - // Clear the Path if picking a new Action ActionInput.CredentialReference.Path = string.Empty; } else diff --git a/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Outgoing/OutgoingDIDComm.razor b/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Outgoing/OutgoingDIDComm.razor deleted file mode 100644 index 5971ac9..0000000 --- a/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Outgoing/OutgoingDIDComm.razor +++ /dev/null @@ -1,102 +0,0 @@ -@* @using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow.Actions *@ -@* *@ -@*
*@ -@*
*@ -@* *@ -@* *@ -@*
*@ -@*
*@ -@* *@ -@* *@ -@*
*@ -@*
*@ -@* *@ -@* *@ -@*
*@ -@*
*@ -@* *@ -@* @foreach (var header in ActionInput.Headers) *@ -@* { *@ -@*
*@ -@* *@ -@* *@ -@* *@ -@*
*@ -@* } *@ -@*
*@ -@* *@ -@* *@ -@* *@ -@*
*@ -@*
*@ -@*
*@ -@* *@ -@* @code { *@ -@* [Parameter] public OutgoingDIDComm ActionInput { get; set; } = null!; *@ -@* [Parameter] public EventCallback OnChange { get; set; } *@ -@* *@ -@* private string newHeaderKey = string.Empty; *@ -@* private string newHeaderValue = string.Empty; *@ -@* *@ -@* private async Task UpdateHeaderKey(string oldKey, string newKey) *@ -@* { *@ -@* if (oldKey != newKey && !string.IsNullOrWhiteSpace(newKey) && !ActionInput.Headers.ContainsKey(newKey)) *@ -@* { *@ -@* var value = ActionInput.Headers[oldKey]; *@ -@* ActionInput.Headers.Remove(oldKey); *@ -@* ActionInput.Headers[newKey] = value; *@ -@* await OnChange.InvokeAsync(); *@ -@* StateHasChanged(); *@ -@* } *@ -@* } *@ -@* *@ -@* private async Task UpdateHeaderValue(string key, string newValue) *@ -@* { *@ -@* ActionInput.Headers[key] = newValue; *@ -@* await OnChange.InvokeAsync(); *@ -@* StateHasChanged(); *@ -@* } *@ -@* *@ -@* private async Task RemoveHeader(string key) *@ -@* { *@ -@* ActionInput.Headers.Remove(key); *@ -@* await OnChange.InvokeAsync(); *@ -@* StateHasChanged(); *@ -@* } *@ -@* *@ -@* private async Task AddHeader() *@ -@* { *@ -@* if (!string.IsNullOrWhiteSpace(newHeaderKey) && !ActionInput.Headers.ContainsKey(newHeaderKey)) *@ -@* { *@ -@* ActionInput.Headers[newHeaderKey] = newHeaderValue; *@ -@* newHeaderKey = string.Empty; *@ -@* newHeaderValue = string.Empty; *@ -@* await OnChange.InvokeAsync(); *@ -@* StateHasChanged(); *@ -@* } *@ -@* } *@ -@* *@ -@* } *@ \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Verification/VerifyW3cSdCredentialAction.razor b/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Verification/VerifyW3cSdCredentialAction.razor index bdb6111..b37a939 100644 --- a/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Verification/VerifyW3cSdCredentialAction.razor +++ b/Blocktrust.CredentialWorkflow.Web/Components/Features/Actions/Verification/VerifyW3cSdCredentialAction.razor @@ -76,7 +76,6 @@ protected override void OnInitialized() { - // Ensure defaults are set if (!ActionInput.CheckSignature && !ActionInput.CheckStatus && !ActionInput.CheckSchema && !ActionInput.CheckTrustRegistry && !ActionInput.CheckExpiry) { diff --git a/Blocktrust.CredentialWorkflow.Web/Components/Features/Outcome/OutcomeActionComponent.razor b/Blocktrust.CredentialWorkflow.Web/Components/Features/Outcome/OutcomeActionComponent.razor deleted file mode 100644 index 0d694f7..0000000 --- a/Blocktrust.CredentialWorkflow.Web/Components/Features/Outcome/OutcomeActionComponent.razor +++ /dev/null @@ -1,244 +0,0 @@ -@* @using Blocktrust.CredentialWorkflow.Core.Domain.ProcessFlow *@ -@* @using Blocktrust.CredentialWorkflow.Core.Domain.Common *@ -@* @namespace Blocktrust.CredentialWorkflow.Web.Components.Features.Outcome *@ -@* *@ -@*
*@ -@*
*@ -@*

*@ -@* @(ActionInput.Type == EOutcomeActionType.Log ? "Log Outcome Configuration" : "Post Outcome Configuration") *@ -@*

*@ -@* *@ -@* @if (ActionInput.Type == EOutcomeActionType.Post) *@ -@* { *@ -@*
*@ -@* *@ -@* *@ -@* *@ -@* @if (!string.IsNullOrEmpty(selectedDeliveryMethod)) *@ -@* { *@ -@*
*@ -@* @if (selectedDeliveryMethod == "http") *@ -@* { *@ -@*
*@ -@*
*@ -@* *@ -@* *@ -@*
*@ -@*
*@ -@* *@ -@*
*@ -@* *@ -@* @if (ActionInput.Destination.Source == ParameterSource.Static) *@ -@* { *@ -@* *@ -@* } *@ -@* else *@ -@* { *@ -@* *@ -@* } *@ -@*
*@ -@*
*@ -@*
*@ -@* } *@ -@* else if (selectedDeliveryMethod == "didcomm") *@ -@* { *@ -@*
*@ -@* *@ -@*
*@ -@* *@ -@* @if (ActionInput.Destination.Source == ParameterSource.Static) *@ -@* { *@ -@* *@ -@* } *@ -@* else *@ -@* { *@ -@* *@ -@* } *@ -@*
*@ -@*
*@ -@* } *@ -@*
*@ -@* } *@ -@*
*@ -@* } *@ -@* *@ -@*
*@ -@*
*@ -@* *@ -@* *@ -@*
*@ -@* @foreach (var field in ActionInput.Content) *@ -@* { *@ -@*
*@ -@* *@ -@* *@ -@* @if (field.Value.Source == ParameterSource.Static) *@ -@* { *@ -@* *@ -@* } *@ -@* else *@ -@* { *@ -@* *@ -@* } *@ -@* *@ -@*
*@ -@* } *@ -@*
*@ -@*
*@ -@*
*@ -@* *@ -@* @code { *@ -@* [Parameter] public OutcomeAction ActionInput { get; set; } = null!; *@ -@* [Parameter] public EventCallback OnChange { get; set; } *@ -@* [Parameter] public IEnumerable? TriggerParameters { get; set; } *@ -@* *@ -@* private string selectedDeliveryMethod = ""; *@ -@* private string httpMethod = "POST"; *@ -@* *@ -@* protected override void OnInitialized() *@ -@* { *@ -@* // Initialize the delivery method based on the destination path if it exists *@ -@* if (!string.IsNullOrEmpty(ActionInput.Destination?.Path)) *@ -@* { *@ -@* if (ActionInput.Destination.Path.StartsWith("did:")) *@ -@* { *@ -@* selectedDeliveryMethod = "didcomm"; *@ -@* } *@ -@* else *@ -@* { *@ -@* selectedDeliveryMethod = "http"; *@ -@* } *@ -@* } *@ -@* } *@ -@* *@ -@* private async Task OnMethodChanged() *@ -@* { *@ -@* // Add method to destination path if using HTTP *@ -@* if (selectedDeliveryMethod == "http" && ActionInput.Destination.Source == ParameterSource.Static) *@ -@* { *@ -@* var url = ActionInput.Destination.Path; *@ -@* if (!string.IsNullOrEmpty(url)) *@ -@* { *@ -@* ActionInput.Destination.Path = $"{httpMethod}|{url}"; *@ -@* await OnChange.InvokeAsync(); *@ -@* } *@ -@* } *@ -@* } *@ -@* *@ -@* private async Task OnValueChanged() *@ -@* { *@ -@* await OnChange.InvokeAsync(); *@ -@* } *@ -@* *@ -@* private async Task AddContentField() *@ -@* { *@ -@* var fieldName = $"field{ActionInput.Content.Count + 1}"; *@ -@* ActionInput.Content[fieldName] = new ParameterReference *@ -@* { *@ -@* Source = ParameterSource.Static *@ -@* }; *@ -@* await OnChange.InvokeAsync(); *@ -@* } *@ -@* *@ -@* private async Task UpdateFieldKey(string oldKey, string newKey) *@ -@* { *@ -@* if (oldKey != newKey && !string.IsNullOrWhiteSpace(newKey)) *@ -@* { *@ -@* var value = ActionInput.Content[oldKey]; *@ -@* ActionInput.Content.Remove(oldKey); *@ -@* ActionInput.Content[newKey] = value; *@ -@* await OnChange.InvokeAsync(); *@ -@* } *@ -@* } *@ -@* *@ -@* private async Task RemoveField(string key) *@ -@* { *@ -@* ActionInput.Content.Remove(key); *@ -@* await OnChange.InvokeAsync(); *@ -@* } *@ -@* } *@ \ No newline at end of file diff --git a/Blocktrust.CredentialWorkflow.Web/Program.cs b/Blocktrust.CredentialWorkflow.Web/Program.cs index 3875abe..d980f34 100644 --- a/Blocktrust.CredentialWorkflow.Web/Program.cs +++ b/Blocktrust.CredentialWorkflow.Web/Program.cs @@ -40,9 +40,8 @@ builder.Services.AddScoped(); // Add Core Services -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); + +// builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped();