diff --git a/EnvelopeGenerator.Application/Common/Extensions/MemoryCacheExtensions.cs b/EnvelopeGenerator.Application/Common/Extensions/MemoryCacheExtensions.cs
index c86bf6d6..1c840213 100644
--- a/EnvelopeGenerator.Application/Common/Extensions/MemoryCacheExtensions.cs
+++ b/EnvelopeGenerator.Application/Common/Extensions/MemoryCacheExtensions.cs
@@ -3,10 +3,22 @@ using Microsoft.Extensions.Caching.Memory;
namespace EnvelopeGenerator.Application.Common.Extensions;
+///
+///
+///
public static class MemoryCacheExtensions
{
private static readonly Guid BaseId = Guid.NewGuid();
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public static IDictionary GetEnumAsDictionary(this IMemoryCache memoryCache, string key = "", params object[] ignores)
where TEnum : Enum
=> memoryCache.GetOrCreate(BaseId + typeof(TEnum).FullName + key, _ =>
diff --git a/EnvelopeGenerator.Application/Common/Extensions/QueryExtensions.cs b/EnvelopeGenerator.Application/Common/Extensions/QueryExtensions.cs
index 1f3ed9b3..3f88be5a 100644
--- a/EnvelopeGenerator.Application/Common/Extensions/QueryExtensions.cs
+++ b/EnvelopeGenerator.Application/Common/Extensions/QueryExtensions.cs
@@ -1,6 +1,7 @@
using DigitalData.Core.Exceptions;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Common.Query;
+using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Domain.Interfaces;
namespace EnvelopeGenerator.Application.Common.Extensions;
@@ -34,6 +35,28 @@ public static class QueryExtensions
return root;
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IQueryable Where(this IQueryable root, EnvelopeQueryBase query, bool notnull = true)
+ {
+ if (query.Id is not null)
+ root = root.Where(e => e.Id == query.Id);
+ else if (query.Uuid is not null)
+ root = root.Where(e => e.Uuid == query.Uuid);
+ else if (notnull)
+ throw new BadRequestException(
+ "Either Envelope Id or Envelope Uuid must be provided in the query."
+ );
+
+ return root;
+ }
+
///
///
///
@@ -60,6 +83,30 @@ public static class QueryExtensions
return root;
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IQueryable Where(this IQueryable root, ReceiverQueryBase query, bool notnull = true)
+ {
+ if (query.Id is not null)
+ root = root.Where(e => e.Id == query.Id);
+ else if (query.EmailAddress is not null)
+ root = root.Where(e => e.EmailAddress == query.EmailAddress);
+ else if (query.Signature is not null)
+ root = root.Where(e => e.Signature == query.Signature);
+ else if (notnull)
+ throw new BadRequestException(
+ "Receiver must have at least one identifier (Id, EmailAddress, or Signature)."
+ );
+
+ return root;
+ }
+
///
///
///
diff --git a/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs
index 377a6f68..73ae86ba 100644
--- a/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs
+++ b/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/SendSignedMailHandler.cs
@@ -1,8 +1,6 @@
using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
using EnvelopeGenerator.Application.Common.Configurations;
-using EnvelopeGenerator.Application.Common.Notifications;
-using EnvelopeGenerator.Application.Common.Notifications.DocSigned;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.Extensions.Options;
diff --git a/EnvelopeGenerator.Application/Common/Query/ReceiverQueryBase.cs b/EnvelopeGenerator.Application/Common/Query/ReceiverQueryBase.cs
index 9cd70341..c998891d 100644
--- a/EnvelopeGenerator.Application/Common/Query/ReceiverQueryBase.cs
+++ b/EnvelopeGenerator.Application/Common/Query/ReceiverQueryBase.cs
@@ -9,12 +9,12 @@ public record ReceiverQueryBase
///
/// ID des Empfängers
///
- public virtual int? Id { get; init; }
+ public virtual int? Id { get; set; }
///
/// E-Mail Adresse des Empfängers
///
- public virtual string? EmailAddress { get; init; }
+ public virtual string? EmailAddress { get; set; }
///
/// Eindeutige Signatur des Empfängers
diff --git a/EnvelopeGenerator.Application/DocStatus/Commands/ModifyDocStatusCommandBase.cs b/EnvelopeGenerator.Application/DocStatus/Commands/ModifyDocStatusCommandBase.cs
index a5ad6054..259cb500 100644
--- a/EnvelopeGenerator.Application/DocStatus/Commands/ModifyDocStatusCommandBase.cs
+++ b/EnvelopeGenerator.Application/DocStatus/Commands/ModifyDocStatusCommandBase.cs
@@ -8,6 +8,21 @@ namespace EnvelopeGenerator.Application.DocStatus.Commands;
///
public record ModifyDocStatusCommandBase : EnvelopeReceiverQueryBase
{
+ ///
+ ///
+ ///
+ public int? EnvelopeId => Envelope.Id;
+
+ ///
+ ///
+ ///
+ public int? ReceiverId => Receiver.Id;
+
+ ///
+ ///
+ ///
+ public override ReceiverQueryBase Receiver { get => base.Receiver; set => base.Receiver = value; }
+
///
/// Gets the current status code.
///
diff --git a/EnvelopeGenerator.Application/DocStatus/Commands/SaveDocStatusCommand.cs b/EnvelopeGenerator.Application/DocStatus/Commands/SaveDocStatusCommand.cs
index 70f1cf1d..0f041e8a 100644
--- a/EnvelopeGenerator.Application/DocStatus/Commands/SaveDocStatusCommand.cs
+++ b/EnvelopeGenerator.Application/DocStatus/Commands/SaveDocStatusCommand.cs
@@ -23,15 +23,23 @@ public class SaveDocStatusCommandHandler : IRequestHandler _repo;
+ private readonly IRepository _envRepo;
+
+ private readonly IRepository _rcvRepo;
+
///
///
///
///
///
- public SaveDocStatusCommandHandler(IMapper mapper, IRepository repo)
+ ///
+ ///
+ public SaveDocStatusCommandHandler(IMapper mapper, IRepository repo, IRepository rcvRepo, IRepository envRepo)
{
_mapper = mapper;
_repo = repo;
+ _rcvRepo = rcvRepo;
+ _envRepo = envRepo;
}
///
@@ -45,6 +53,12 @@ public class SaveDocStatusCommandHandler : IRequestHandler();
diff --git a/EnvelopeGenerator.Application/DocStatus/MappingProfile.cs b/EnvelopeGenerator.Application/DocStatus/MappingProfile.cs
index b04b47e7..eb420037 100644
--- a/EnvelopeGenerator.Application/DocStatus/MappingProfile.cs
+++ b/EnvelopeGenerator.Application/DocStatus/MappingProfile.cs
@@ -14,7 +14,12 @@ public class MappingProfile : Profile
///
public MappingProfile()
{
- CreateMap();
- CreateMap();
+ CreateMap()
+ .ForMember(dest => dest.Envelope, opt => opt.Ignore())
+ .ForMember(dest => dest.Receiver, opt => opt.Ignore());
+
+ CreateMap()
+ .ForMember(dest => dest.Envelope, opt => opt.Ignore())
+ .ForMember(dest => dest.Receiver, opt => opt.Ignore());
}
-}
+}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReadEnvelopeReceiverQuery.cs b/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReadEnvelopeReceiverQuery.cs
index 211bee2a..6f8b63da 100644
--- a/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReadEnvelopeReceiverQuery.cs
+++ b/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReadEnvelopeReceiverQuery.cs
@@ -113,7 +113,7 @@ public class ReadEnvelopeReceiverQueryHandler : IRequestHandler
public async Task> Handle(ReadEnvelopeReceiverQuery request, CancellationToken cancel)
{
- var q = _repo.Read().Where(request, notnull: false);
+ var q = _repo.ReadOnly().Where(request, notnull: false);
if (request.Envelope.Status is not null)
{
diff --git a/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReceiverAlreadySignedQuery.cs b/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReceiverAlreadySignedQuery.cs
index 8255a43c..3b5fbf8c 100644
--- a/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReceiverAlreadySignedQuery.cs
+++ b/EnvelopeGenerator.Application/EnvelopeReceivers/Queries/ReceiverAlreadySignedQuery.cs
@@ -68,6 +68,6 @@ public class ReceiverAlreadySignedQueryHandler : IRequestHandler
public async Task Handle(ReceiverAlreadySignedQuery request, CancellationToken cancel = default)
{
- return await _repo.Read().Where(request).Where(h => h.Status == EnvelopeStatus.DocumentSigned).AnyAsync(cancel);
+ return await _repo.ReadOnly().Where(request).Where(h => h.Status == EnvelopeStatus.DocumentSigned).AnyAsync(cancel);
}
}
\ No newline at end of file