diff --git a/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs b/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs index 81d78eb8..87758a4f 100644 --- a/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs +++ b/EnvelopeGenerator.Application/Annotations/Commands/CreateAnnotationCommand.cs @@ -5,6 +5,8 @@ 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; @@ -14,11 +16,36 @@ namespace EnvelopeGenerator.Application.Annotations.Commands; /// public record CreateAnnotationCommand : EnvelopeReceiverQueryBase, IRequest> { + /// + /// + /// + public CreateAnnotationCommand() + { + _lazyPSPDFKitInstant = new(() => + { + var options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true, + PropertyNamingPolicy = null + }; + + return JsonSerializer.Deserialize(PSPDFKitInstantJSON, options) ?? new ExpandoObject(); + }); + } + /// /// /// [JsonIgnore] public string PSPDFKitInstantJSON { get; set; } = null!; + + private readonly Lazy _lazyPSPDFKitInstant; + + /// + /// + /// + [JsonIgnore] + public ExpandoObject PSPDFKitInstant => _lazyPSPDFKitInstant.Value; } /// @@ -72,7 +99,7 @@ public class CreateAnnotationCommandHandler : IRequestHandler new Annotation() { ElementId = element.Id, @@ -90,10 +117,10 @@ public class CreateAnnotationCommandHandler : IRequestHandler /// /// - /// + /// /// /// - public static Dictionary ParsePSPDFKitInstantJSON(string json, int elementId) + public static Dictionary ParsePSPDFKitInstant(ExpandoObject instant, int elementId) { Dictionary annots = new();