diff --git a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentMappingProfile.cs b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentMappingProfile.cs
deleted file mode 100644
index ac9c9b18..00000000
--- a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentMappingProfile.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using AutoMapper;
-using EnvelopeGenerator.Domain.Entities;
-
-namespace EnvelopeGenerator.Application.Documents.Queries.Read;
-
-///
-///
-///
-public class ReadDocumentMappingProfile : Profile
-{
- ///
- ///
- ///
- public ReadDocumentMappingProfile()
- {
- CreateMap();
- }
-}
diff --git a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQuery.cs b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQuery.cs
deleted file mode 100644
index be3fc0c6..00000000
--- a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQuery.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using MediatR;
-
-namespace EnvelopeGenerator.Application.Documents.Queries.Read;
-
-///
-/// Represents a query to read a document based on its unique identifier or associated envelope identifier.
-///
-/// The unique identifier of the document. Optional.
-/// The identifier of the envelope associated with the document. Optional.
-public record ReadDocumentQuery(int? Id = null, int? EnvelopeId = null) : IRequest
-{
-}
diff --git a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponse.cs b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponse.cs
deleted file mode 100644
index 3fc4d222..00000000
--- a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponse.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace EnvelopeGenerator.Application.Documents.Queries.Read;
-
-///
-/// Represents the response for reading a document.
-///
-public class ReadDocumentResponse : ReadDocumentResponseBase
-{
- ///
- /// The binary data of the document, if available.
- ///
- public byte[]? ByteData { get; init; }
-}
diff --git a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponseBase.cs b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponseBase.cs
deleted file mode 100644
index afa13cb2..00000000
--- a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponseBase.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace EnvelopeGenerator.Application.Documents.Queries.Read;
-
-///
-/// Represents the response for reading a document.
-///
-public class ReadDocumentResponseBase
-{
- ///
- /// The unique identifier of the document.
- ///
- public int Guid { get; init; }
-
- ///
- /// The identifier of the associated envelope.
- ///
- public int EnvelopeId { get; init; }
-
- ///
- /// The date and time when the document was added.
- ///
- public DateTime AddedWhen { get; init; }
-}
diff --git a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQueryHandler.cs b/EnvelopeGenerator.Application/Documents/Queries/ReadDocumentQuery.cs
similarity index 62%
rename from EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQueryHandler.cs
rename to EnvelopeGenerator.Application/Documents/Queries/ReadDocumentQuery.cs
index 2dcec29e..bc0a4b43 100644
--- a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQueryHandler.cs
+++ b/EnvelopeGenerator.Application/Documents/Queries/ReadDocumentQuery.cs
@@ -1,13 +1,23 @@
using DigitalData.Core.Abstraction.Application.Repository;
-using EnvelopeGenerator.Domain.Entities;
+using EnvelopeGenerator.Application.Dto;
using MediatR;
+using EnvelopeGenerator.Domain.Entities;
-namespace EnvelopeGenerator.Application.Documents.Queries.Read;
+namespace EnvelopeGenerator.Application.Documents.Queries;
+
+///
+/// Represents a query to read a document based on its unique identifier or associated envelope identifier.
+///
+/// The unique identifier of the document. Optional.
+/// The identifier of the envelope associated with the document. Optional.
+public record ReadDocumentQuery(int? Id = null, int? EnvelopeId = null) : IRequest
+{
+}
///
/// Handles queries for reading data based on either the document ID or the envelope ID.
///
-public class ReadDocumentQueryHandler : IRequestHandler
+public class ReadDocumentQueryHandler : IRequestHandler
{
///
/// Repository for accessing entities.
@@ -24,25 +34,25 @@ public class ReadDocumentQueryHandler : IRequestHandler
- /// Handles the and returns a based on the provided identifiers.
+ /// Handles the and returns a based on the provided identifiers.
///
/// The query containing the document ID or envelope ID to search for.
/// A token to monitor for cancellation requests.
///
- /// A if a matching document is found; otherwise, null.
+ /// A if a matching document is found; otherwise, null.
///
///
/// Thrown when neither nor is provided.
///
[Obsolete("Use MediatR")]
- public async Task Handle(ReadDocumentQuery query, CancellationToken cancellationToken)
+ public async Task Handle(ReadDocumentQuery query, CancellationToken cancellationToken)
{
if (query.Id is not null)
- return await _repo.ReadOrDefaultAsync(d => d.Id == query.Id);
+ return await _repo.ReadOrDefaultAsync(d => d.Id == query.Id);
else if (query.EnvelopeId is not null)
- return await _repo.ReadOrDefaultAsync(d => d.EnvelopeId == query.EnvelopeId);
+ return await _repo.ReadOrDefaultAsync(d => d.EnvelopeId == query.EnvelopeId);
throw new InvalidOperationException(
$"Invalid {nameof(ReadDocumentQuery)}: either {nameof(query.Id)} or {nameof(query.EnvelopeId)} must be provided.");
}
-}
+}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Terminal/CommandManager.cs b/EnvelopeGenerator.Terminal/CommandManager.cs
index c4fe43d7..f31f2739 100644
--- a/EnvelopeGenerator.Terminal/CommandManager.cs
+++ b/EnvelopeGenerator.Terminal/CommandManager.cs
@@ -1,6 +1,6 @@
using CommandDotNet;
using EnvelopeGenerator.Application.Contracts.Services;
-using EnvelopeGenerator.Application.Documents.Queries.Read;
+using EnvelopeGenerator.Application.Documents.Queries;
using MediatR;
using System.Reflection;
using System.Text.Json;
@@ -45,12 +45,12 @@ public class CommandManager
{
ReadDocumentQuery query = new(id, envelopeId);
var document = await _mediator.Send(query);
- console.WriteLine(JsonSerializer.Serialize(save ? document as ReadDocumentResponseBase : document, Options));
+ console.WriteLine(JsonSerializer.Serialize(save ? document as ReadDocumentResponse : document, Options));
if (save)
{
dir ??= AppContext.BaseDirectory;
- fileName ??= $"D{document?.Guid}E{document?.EnvelopeId}.pdf";
+ fileName ??= $"D{document?.Id}E{document?.EnvelopeId}.pdf";
var path = Path.Combine(dir, fileName);
console.WriteLine("Save to " + path);