refactor(ReadDocumentQuery): update to add CancellationToken
This commit is contained in:
parent
8a4d3ff6f9
commit
dfa1667939
@ -32,6 +32,7 @@ public class ReadDocumentQueryHandler : IRequestHandler<ReadDocumentQuery, Envel
|
|||||||
/// Initializes a new instance of the <see cref="ReadDocumentQueryHandler"/> class.
|
/// Initializes a new instance of the <see cref="ReadDocumentQueryHandler"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="envelopeDocumentRepository">The repository used to access <see cref="EnvelopeDocument"/> entities.</param>
|
/// <param name="envelopeDocumentRepository">The repository used to access <see cref="EnvelopeDocument"/> entities.</param>
|
||||||
|
/// <param name="mapper"></param>
|
||||||
public ReadDocumentQueryHandler(IRepository<EnvelopeDocument> envelopeDocumentRepository, IMapper mapper)
|
public ReadDocumentQueryHandler(IRepository<EnvelopeDocument> envelopeDocumentRepository, IMapper mapper)
|
||||||
{
|
{
|
||||||
_repo = envelopeDocumentRepository;
|
_repo = envelopeDocumentRepository;
|
||||||
@ -42,24 +43,23 @@ public class ReadDocumentQueryHandler : IRequestHandler<ReadDocumentQuery, Envel
|
|||||||
/// Handles the <see cref="ReadDocumentQuery"/> and returns a <see cref="EnvelopeDocumentDto"/> based on the provided identifiers.
|
/// Handles the <see cref="ReadDocumentQuery"/> and returns a <see cref="EnvelopeDocumentDto"/> based on the provided identifiers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="query">The query containing the document ID or envelope ID to search for.</param>
|
/// <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>
|
/// <param name="cancel">A token to monitor for cancellation requests.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A <see cref="EnvelopeDocumentDto"/> if a matching document is found; otherwise, <c>null</c>.
|
/// A <see cref="EnvelopeDocumentDto"/> if a matching document is found; otherwise, <c>null</c>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="InvalidOperationException">
|
/// <exception cref="InvalidOperationException">
|
||||||
/// Thrown when neither <see cref="ReadDocumentQuery.Id"/> nor <see cref="ReadDocumentQuery.EnvelopeId"/> is provided.
|
/// Thrown when neither <see cref="ReadDocumentQuery.Id"/> nor <see cref="ReadDocumentQuery.EnvelopeId"/> is provided.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
[Obsolete("Use MediatR")]
|
public async Task<EnvelopeDocumentDto?> Handle(ReadDocumentQuery query, CancellationToken cancel)
|
||||||
public async Task<EnvelopeDocumentDto?> Handle(ReadDocumentQuery query, CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
if (query.Id is not null)
|
if (query.Id is not null)
|
||||||
{
|
{
|
||||||
var doc = await _repo.ReadOnly().Where(d => d.Id == query.Id).FirstOrDefaultAsync();
|
var doc = await _repo.ReadOnly().Where(d => d.Id == query.Id).FirstOrDefaultAsync(cancel);
|
||||||
return _mapper.Map<EnvelopeDocumentDto>(doc);
|
return _mapper.Map<EnvelopeDocumentDto>(doc);
|
||||||
}
|
}
|
||||||
else if (query.EnvelopeId is not null)
|
else if (query.EnvelopeId is not null)
|
||||||
{
|
{
|
||||||
var doc = await _repo.ReadOnly().Where(d => d.EnvelopeId == query.EnvelopeId).FirstOrDefaultAsync();
|
var doc = await _repo.ReadOnly().Where(d => d.EnvelopeId == query.EnvelopeId).FirstOrDefaultAsync(cancel);
|
||||||
return _mapper.Map<EnvelopeDocumentDto>(doc);
|
return _mapper.Map<EnvelopeDocumentDto>(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user