refactor(CreateAnnotationCommand): update to return IEnumerable<Signature> as result
This commit is contained in:
parent
f56928f44f
commit
5e53f2b691
@ -1,4 +1,5 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using AngleSharp.Dom;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.Common.Extensions;
|
||||
using EnvelopeGenerator.Application.Common.Query;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
@ -11,7 +12,7 @@ namespace EnvelopeGenerator.Application.Annotations.Commands;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record CreateAnnotationCommand : EnvelopeReceiverQueryBase, IRequest
|
||||
public record CreateAnnotationCommand : EnvelopeReceiverQueryBase, IRequest<IEnumerable<Signature>>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@ -23,7 +24,7 @@ public record CreateAnnotationCommand : EnvelopeReceiverQueryBase, IRequest
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateAnnotationCommandHandler : IRequestHandler<CreateAnnotationCommand>
|
||||
public class CreateAnnotationCommandHandler : IRequestHandler<CreateAnnotationCommand, IEnumerable<Signature>>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@ -39,6 +40,7 @@ public class CreateAnnotationCommandHandler : IRequestHandler<CreateAnnotationCo
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="signRepo"></param>
|
||||
/// <param name="annotRepo"></param>
|
||||
public CreateAnnotationCommandHandler(IRepository<Signature> signRepo, IRepository<Annotation> annotRepo)
|
||||
{
|
||||
_signRepo = signRepo;
|
||||
@ -51,8 +53,7 @@ public class CreateAnnotationCommandHandler : IRequestHandler<CreateAnnotationCo
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task Handle(CreateAnnotationCommand request, CancellationToken cancel)
|
||||
public async Task<IEnumerable<Signature>> Handle(CreateAnnotationCommand request, CancellationToken cancel)
|
||||
{
|
||||
var query = _signRepo.Query;
|
||||
|
||||
@ -67,7 +68,7 @@ public class CreateAnnotationCommandHandler : IRequestHandler<CreateAnnotationCo
|
||||
// Receiver Query
|
||||
query = query.Where(request.Receiver);
|
||||
|
||||
var elements = await query.ToListAsync(cancel);
|
||||
var elements = await query.ToListAsync(cancel);
|
||||
|
||||
foreach (var element in elements)
|
||||
{
|
||||
@ -80,8 +81,10 @@ public class CreateAnnotationCommandHandler : IRequestHandler<CreateAnnotationCo
|
||||
AddedWhen = DateTime.UtcNow
|
||||
});
|
||||
|
||||
await _annotRepo.CreateAsync(annots, cancel);
|
||||
element.Annotations = await _annotRepo.CreateAsync(annots, cancel);
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user