feat(ReadDocumentQueryHandler): Logik hinzugefügt
This commit is contained in:
parent
45d39069aa
commit
975beff416
@ -7,6 +7,6 @@ namespace EnvelopeGenerator.Application.Documents.Queries.Read;
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the document. Optional.</param>
|
||||
/// <param name="EnvelopeId">The identifier of the envelope associated with the document. Optional.</param>
|
||||
public record ReadDocumentQuery(int? Id = null, int? EnvelopeId = null) : IRequest<ReadDocumentResponse>
|
||||
public record ReadDocumentQuery(int? Id = null, int? EnvelopeId = null) : IRequest<ReadDocumentResponse?>
|
||||
{
|
||||
}
|
||||
|
||||
@ -1,19 +1,48 @@
|
||||
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
using DigitalData.Core.Abstractions.Infrastructure;
|
||||
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Documents.Queries.Read;
|
||||
|
||||
public class ReadDocumentQueryHandler : IRequestHandler<ReadDocumentQuery, ReadDocumentResponse>
|
||||
/// <summary>
|
||||
/// Handles queries for reading <see cref="EnvelopeDocument"/> data based on either the document ID or the envelope ID.
|
||||
/// </summary>
|
||||
public class ReadDocumentQueryHandler : IRequestHandler<ReadDocumentQuery, ReadDocumentResponse?>
|
||||
{
|
||||
public IEnvelopeDocumentRepository _repo;
|
||||
/// <summary>
|
||||
/// Repository for accessing <see cref="EnvelopeDocument"/> entities.
|
||||
/// </summary>
|
||||
private readonly IRepository<EnvelopeDocument> _repo;
|
||||
|
||||
public ReadDocumentQueryHandler(IEnvelopeDocumentRepository envelopeDocumentRepository)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReadDocumentQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="envelopeDocumentRepository">The repository used to access <see cref="EnvelopeDocument"/> entities.</param>
|
||||
public ReadDocumentQueryHandler(IRepository<EnvelopeDocument> envelopeDocumentRepository)
|
||||
{
|
||||
_repo = envelopeDocumentRepository;
|
||||
}
|
||||
|
||||
public Task<ReadDocumentResponse> Handle(ReadDocumentQuery query, CancellationToken cancellationToken)
|
||||
/// <summary>
|
||||
/// Handles the <see cref="ReadDocumentQuery"/> and returns a <see cref="ReadDocumentResponse"/> based on the provided identifiers.
|
||||
/// </summary>
|
||||
/// <param name="query">The query containing the document ID or envelope ID to search for.</param>
|
||||
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="ReadDocumentResponse"/> if a matching document is found; otherwise, <c>null</c>.
|
||||
/// </returns>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown when neither <see cref="ReadDocumentQuery.Id"/> nor <see cref="ReadDocumentQuery.EnvelopeId"/> is provided.
|
||||
/// </exception>
|
||||
public async Task<ReadDocumentResponse?> Handle(ReadDocumentQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (query.Id is not null)
|
||||
return await _repo.ReadOrDefaultAsync<ReadDocumentResponse>(d => d.Id == query.Id);
|
||||
else if (query.EnvelopeId is not null)
|
||||
return await _repo.ReadOrDefaultAsync<ReadDocumentResponse>(d => d.EnvelopeId == query.EnvelopeId);
|
||||
|
||||
throw new InvalidOperationException(
|
||||
$"Invalid {nameof(ReadDocumentQuery)}: either {nameof(query.Id)} or {nameof(query.EnvelopeId)} must be provided.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.2" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.3" />
|
||||
<PackageReference Include="DigitalData.Core.Application" Version="3.2.1" />
|
||||
<PackageReference Include="DigitalData.Core.Client" Version="2.0.3" />
|
||||
<PackageReference Include="DigitalData.Core.DTO" Version="2.0.1" />
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.2" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.3" />
|
||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher.Abstraction" Version="3.0.0" />
|
||||
<PackageReference Include="UserManager.Domain" Version="3.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.2" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.3" />
|
||||
<PackageReference Include="DigitalData.Core.Application" Version="3.2.1" />
|
||||
<PackageReference Include="DigitalData.Core.DTO" Version="2.0.1" />
|
||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher.Abstraction" Version="3.0.0" />
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.2" />
|
||||
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.0.3" />
|
||||
<PackageReference Include="DigitalData.Core.Infrastructure.AutoMapper" Version="1.0.1" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.3" />
|
||||
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.0.4" />
|
||||
<PackageReference Include="DigitalData.Core.Infrastructure.AutoMapper" Version="1.0.2" />
|
||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.0.0" />
|
||||
<PackageReference Include="UserManager" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<PackageReference Include="CommandDotNet" Version="8.1.1" />
|
||||
<PackageReference Include="CommandDotNet.IoC.MicrosoftDependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="CommandDotNet.NameCasing" Version="5.1.0" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.2" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.3" />
|
||||
<PackageReference Include="DigitalData.Core.API" Version="2.1.1" />
|
||||
<PackageReference Include="DigitalData.Core.Application" Version="3.2.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.4" />
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.2" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.3" />
|
||||
<PackageReference Include="DigitalData.Core.API" Version="2.1.1" />
|
||||
<PackageReference Include="DigitalData.Core.Application" Version="3.2.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
|
||||
|
||||
@ -2101,7 +2101,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="BuildBundlerMinifier2022" Version="2.9.9" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.2" />
|
||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="3.4.3" />
|
||||
<PackageReference Include="DigitalData.Core.API" Version="2.1.1" />
|
||||
<PackageReference Include="DigitalData.Core.Application" Version="3.2.1" />
|
||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.0.0" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user