update to use IRepository<T>
This commit is contained in:
parent
3b7d0e1321
commit
e96523b786
@ -8,13 +8,13 @@ namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Han
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RemoveAnnotationHandler : INotificationHandler<RemoveSignatureNotification>
|
public class RemoveAnnotationHandler : INotificationHandler<RemoveSignatureNotification>
|
||||||
{
|
{
|
||||||
private readonly IRepository _repo;
|
private readonly IRepository<Domain.Entities.DocumentStatus> _repo;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="repository"></param>
|
/// <param name="repository"></param>
|
||||||
public RemoveAnnotationHandler(IRepository repository)
|
public RemoveAnnotationHandler(IRepository<Domain.Entities.DocumentStatus> repository)
|
||||||
{
|
{
|
||||||
_repo = repository;
|
_repo = repository;
|
||||||
}
|
}
|
||||||
@ -27,6 +27,6 @@ public class RemoveAnnotationHandler : INotificationHandler<RemoveSignatureNotif
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task Handle(RemoveSignatureNotification notification, CancellationToken cancel)
|
public async Task Handle(RemoveSignatureNotification notification, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
await _repo.DeleteAsync<Domain.Entities.DocumentStatus>(s => s.EnvelopeId == notification.EnvelopeId, cancel);
|
await _repo.DeleteAsync(s => s.Envelope!.Uuid == notification.EnvelopeUuid, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,13 +12,13 @@ namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature.Han
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RemoveHistoryHandler : INotificationHandler<RemoveSignatureNotification>
|
public class RemoveHistoryHandler : INotificationHandler<RemoveSignatureNotification>
|
||||||
{
|
{
|
||||||
private readonly IRepository _repo;
|
private readonly IRepository<Domain.Entities.History> _repo;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="repository"></param>
|
/// <param name="repository"></param>
|
||||||
public RemoveHistoryHandler(IRepository repository)
|
public RemoveHistoryHandler(IRepository<Domain.Entities.History> repository)
|
||||||
{
|
{
|
||||||
_repo = repository;
|
_repo = repository;
|
||||||
}
|
}
|
||||||
@ -31,9 +31,9 @@ public class RemoveHistoryHandler : INotificationHandler<RemoveSignatureNotifica
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task Handle(RemoveSignatureNotification notification, CancellationToken cancel)
|
public async Task Handle(RemoveSignatureNotification notification, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
await _repo.DeleteAsync<Domain.Entities.History>(hists
|
await _repo.DeleteAsync(hists
|
||||||
=> hists
|
=> hists
|
||||||
.Where(hist => hist.EnvelopeId == notification.EnvelopeId)
|
.Where(hist => hist.Envelope!.Uuid == notification.EnvelopeUuid)
|
||||||
.Where(hist => hist.Status == EnvelopeStatus.DocumentSigned)
|
.Where(hist => hist.Status == EnvelopeStatus.DocumentSigned)
|
||||||
, cancel);
|
, cancel);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,5 +5,5 @@ namespace EnvelopeGenerator.Application.Common.Notifications.RemoveSignature;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="EnvelopeId"></param>
|
/// <param name="EnvelopeUuid"></param>
|
||||||
public record RemoveSignatureNotification(int EnvelopeId) : INotification;
|
public record RemoveSignatureNotification(string EnvelopeUuid) : INotification;
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Extensions;
|
||||||
|
using EnvelopeGenerator.Application.Common.Notifications.RemoveSignature;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||||
|
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class TestAnnotationController : ControllerBase
|
||||||
|
{
|
||||||
|
private IMediator _mediator;
|
||||||
|
|
||||||
|
public TestAnnotationController(IMediator mediator)
|
||||||
|
{
|
||||||
|
_mediator = mediator;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{envelopeKey}")]
|
||||||
|
public async Task<IActionResult> Delete([FromRoute] string envelopeKey)
|
||||||
|
{
|
||||||
|
var uuid = envelopeKey.GetEnvelopeUuid();
|
||||||
|
|
||||||
|
if (uuid == null)
|
||||||
|
return BadRequest();
|
||||||
|
|
||||||
|
await _mediator.Publish(new RemoveSignatureNotification(uuid));
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user