diff --git a/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs b/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs
deleted file mode 100644
index 8aba3f4e..00000000
--- a/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-using DigitalData.Core.Abstraction.Application.Repository;
-using EnvelopeGenerator.Application.Common.Extensions;
-using EnvelopeGenerator.Application.Common.Query;
-using EnvelopeGenerator.Domain.Entities;
-using MediatR;
-using Microsoft.EntityFrameworkCore;
-using System.Dynamic;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-
-namespace EnvelopeGenerator.Application.Annotations.Commands;
-
-///
-///
-///
-public record CreateAnnotationCommand : EnvelopeReceiverQueryBase, IRequest>
-{
- private static readonly JsonSerializerOptions SerializerOptions = new()
- {
- PropertyNameCaseInsensitive = true,
- PropertyNamingPolicy = null
- };
-
- ///
- ///
- ///
- [JsonIgnore]
- public string PSPDFKitInstantJSON
- {
- set => PSPDFKitInstant = JsonSerializer.Deserialize(value, SerializerOptions) ?? new ExpandoObject();
- }
-
- ///
- ///
- ///
- [JsonIgnore]
- public ExpandoObject PSPDFKitInstant { get; set; } = null!;
-}
-
-///
-///
-///
-public static class CreateAnnotationCommandExtensions
-{
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static Task> CreateAnnotation(this ISender sender, string envelopeKey, CancellationToken cancel = default)
- => sender.Send(new CreateAnnotationCommand() { Key = envelopeKey }, cancel);
-}
-
-///
-///
-///
-public class CreateAnnotationCommandHandler : IRequestHandler>
-{
- ///
- ///
- ///
- private readonly IRepository _signRepo;
-
- ///
- ///
- ///
- private readonly IRepository _annotRepo;
-
- ///
- ///
- ///
- ///
- ///
- public CreateAnnotationCommandHandler(IRepository signRepo, IRepository annotRepo)
- {
- _signRepo = signRepo;
- _annotRepo = annotRepo;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task> Handle(CreateAnnotationCommand request, CancellationToken cancel)
- {
- var query = _signRepo.Query;
-
- #region Envelope Query
- if (request.Envelope.Id is int envelopeId)
- query = query.Where(annot => annot.Document.EnvelopeId == envelopeId);
-
- if (request.Envelope.Uuid is string envelopeUuid)
- query = query.Where(annot => annot.Document.Envelope!.Uuid == envelopeUuid);
- #endregion
-
- // Receiver Query
- query = query.Where(request.Receiver);
-
- var elements = await query.ToListAsync(cancel);
-
- foreach (var element in elements)
- {
- var annots = ParsePSPDFKitInstant(request.PSPDFKitInstant, element.Id)
- .Select(annot => new Annotation()
- {
- ElementId = element.Id,
- Name = annot.Key,
- Value = annot.Value,
- AddedWhen = DateTime.UtcNow
- });
-
- element.Annotations = await _annotRepo.CreateAsync(annots, cancel);
- }
-
- return elements;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public static Dictionary ParsePSPDFKitInstant(ExpandoObject instant, int elementId)
- {
- Dictionary annots = new();
-
- // parse json here
-
- return annots;
- }
-}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/Annotations/MappingProfile.cs b/EnvelopeGenerator.Application/Annotations/MappingProfile.cs
deleted file mode 100644
index f608b824..00000000
--- a/EnvelopeGenerator.Application/Annotations/MappingProfile.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using AutoMapper;
-using EnvelopeGenerator.Application.Annotations.Commands;
-using EnvelopeGenerator.Domain.Entities;
-
-namespace EnvelopeGenerator.Application.Annotations;
-
-///
-///
-///
-public class MappingProfile : Profile
-{
- ///
- ///
- ///
- public MappingProfile()
- {
- CreateMap()
- .ForMember(dest => dest.AddedWhen, opt => opt.MapFrom(_ => DateTime.UtcNow));
- }
-}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/Common/Dto/AnnotationDto.cs b/EnvelopeGenerator.Application/Common/Dto/AnnotationDto.cs
index 9adb2289..42b96386 100644
--- a/EnvelopeGenerator.Application/Common/Dto/AnnotationDto.cs
+++ b/EnvelopeGenerator.Application/Common/Dto/AnnotationDto.cs
@@ -3,13 +3,8 @@
///
///
///
-public record AnnotationDto
+public record AnnotationCreateDto
{
- ///
- ///
- ///
- public long Id { get; init; }
-
///
///
///
@@ -25,6 +20,22 @@ public record AnnotationDto
///
public string Value { get; init; } = null!;
+ ///
+ ///
+ ///
+ public string Type { get; init; } = null!;
+}
+
+///
+///
+///
+public record AnnotationDto : AnnotationCreateDto
+{
+ ///
+ ///
+ ///
+ public long Id { get; init; }
+
///
///
///
diff --git a/EnvelopeGenerator.Application/Common/Dto/MappingProfile.cs b/EnvelopeGenerator.Application/Common/Dto/MappingProfile.cs
index 72bfda9f..4c01a07b 100644
--- a/EnvelopeGenerator.Application/Common/Dto/MappingProfile.cs
+++ b/EnvelopeGenerator.Application/Common/Dto/MappingProfile.cs
@@ -51,6 +51,8 @@ public class MappingProfile : Profile
CreateMap().ForMember(rcv => rcv.EnvelopeReceivers, rcvReadDto => rcvReadDto.Ignore());
CreateMap();
CreateMap();
+ CreateMap()
+ .ForMember(dest => dest.AddedWhen, opt => opt.MapFrom(_ => DateTime.UtcNow));
// Messaging mappings
// for GTX messaging
diff --git a/EnvelopeGenerator.Application/Common/Notifications/DocSigned/DocSignedNotification.cs b/EnvelopeGenerator.Application/Common/Notifications/DocSigned/DocSignedNotification.cs
index a51ce574..50874c56 100644
--- a/EnvelopeGenerator.Application/Common/Notifications/DocSigned/DocSignedNotification.cs
+++ b/EnvelopeGenerator.Application/Common/Notifications/DocSigned/DocSignedNotification.cs
@@ -1,4 +1,4 @@
-using EnvelopeGenerator.Application.Annotations.Commands;
+using EnvelopeGenerator.Application.Common.Dto;
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Domain.Constants;
@@ -12,7 +12,7 @@ namespace EnvelopeGenerator.Application.Common.Notifications.DocSigned;
///
///
///
-public record PsPdfKitAnnotation(ExpandoObject Instant, IEnumerable Structured);
+public record PsPdfKitAnnotation(ExpandoObject Instant, IEnumerable Structured);
///
///
diff --git a/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/AnnotationHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/AnnotationHandler.cs
index baf6d254..9b7f1cdd 100644
--- a/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/AnnotationHandler.cs
+++ b/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/AnnotationHandler.cs
@@ -1,4 +1,5 @@
-using EnvelopeGenerator.Application.Annotations.Commands;
+using DigitalData.Core.Abstraction.Application.Repository;
+using EnvelopeGenerator.Domain.Entities;
using MediatR;
namespace EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers;
@@ -11,15 +12,15 @@ public class AnnotationHandler : INotificationHandler
///
///
///
- private readonly ISender _sender;
+ private readonly IRepository _repo;
///
///
///
- ///
- public AnnotationHandler(ISender sender)
+ ///
+ public AnnotationHandler(IRepository repository)
{
- _sender = sender;
+ _repo = repository;
}
///
@@ -28,11 +29,6 @@ public class AnnotationHandler : INotificationHandler
///
///
///
- ///
- public Task Handle(DocSignedNotification notification, CancellationToken cancel) => _sender.Send(new CreateAnnotationCommand()
- {
- Envelope = new() { Id = notification.EnvelopeId },
- Receiver = new() { Id = notification.ReceiverId },
- PSPDFKitInstant = notification.PsPdfKitAnnotation.Instant
- }, cancel);
-}
+ public Task Handle(DocSignedNotification notification, CancellationToken cancel)
+ => _repo.CreateAsync(notification.PsPdfKitAnnotation.Structured, cancel);
+}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs b/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs
index fc38b708..c04d0485 100644
--- a/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs
+++ b/EnvelopeGenerator.Web/Controllers/Test/TestAnnotationController.cs
@@ -1,5 +1,4 @@
-using EnvelopeGenerator.Application.Annotations.Commands;
-using EnvelopeGenerator.Application.Common.Extensions;
+using EnvelopeGenerator.Application.Common.Extensions;
using EnvelopeGenerator.Application.Common.Notifications.RemoveSignature;
using MediatR;
using Microsoft.AspNetCore.Mvc;
@@ -28,11 +27,4 @@ public class TestAnnotationController : ControllerBase
await _mediator.Publish(new RemoveSignatureNotification(uuid));
return Ok();
}
-
- [HttpPost("{envelopeKey}")]
- public async Task Create([FromRoute] string envelopeKey, CancellationToken cancel)
- {
- var annot = await _mediator.CreateAnnotation(envelopeKey, cancel);
- return Ok(annot);
- }
}
\ No newline at end of file