diff --git a/EnvelopeGenerator.API/Controllers/AnnotationController.cs b/EnvelopeGenerator.API/Controllers/AnnotationController.cs index be40fb0d..a25bf0e7 100644 --- a/EnvelopeGenerator.API/Controllers/AnnotationController.cs +++ b/EnvelopeGenerator.API/Controllers/AnnotationController.cs @@ -1,16 +1,19 @@ using DigitalData.Core.Abstraction.Application.DTO; using DigitalData.Core.Exceptions; +using EnvelopeGenerator.API.Extensions; +using EnvelopeGenerator.Application.Common.Dto; using EnvelopeGenerator.Application.Common.Extensions; using EnvelopeGenerator.Application.Common.Interfaces.Services; using EnvelopeGenerator.Application.Common.Notifications.DocSigned; +using EnvelopeGenerator.Application.Documents.Queries; using EnvelopeGenerator.Application.EnvelopeReceivers.Queries; using EnvelopeGenerator.Application.Histories.Queries; using EnvelopeGenerator.Domain.Constants; -using EnvelopeGenerator.API.Extensions; using MediatR; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Mvc; namespace EnvelopeGenerator.API.Controllers; @@ -115,4 +118,32 @@ public class AnnotationController : ControllerBase _logger.LogNotice(histRes.Notices); return StatusCode(500, histRes.Messages); } + + //TODO: update to use + /// + /// + /// + /// + /// + /// + [Authorize(Policy = AuthPolicy.Receiver)] + [HttpGet("{envelopeKey}")] + public async Task GetAnnotsOfReceiver(string envelopeKey, CancellationToken cancel) + { + int envelopeId = User.GetEnvelopeIdOfReceiver(); + + int receiverId = User.GetReceiverIdOfReceiver(); + + var doc = await _mediator.Send(new ReadDocumentQuery() { EnvelopeId = envelopeId }, cancel); + + if (doc.Elements is not IEnumerable docSignatures) + return NotFound("Document is empty."); + + var rcvSignatures = docSignatures.Where(s => s.ReceiverId == receiverId).ToList(); + + if (rcvSignatures is null) + return NotFound("No signatures found for the current receiver."); + else + return Ok(rcvSignatures); + } }