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