Renamed `SignatureDto` to `DocReceiverElementDto` across the codebase to better reflect its purpose as a DTO for document receiver elements. Updated all references, including: - `SignatureController.cs`: Changed `doc.Elements` type to `IEnumerable<DocReceiverElementDto>`. - `DocumentDto.cs`: Updated `Elements` property type. - `MappingProfile.cs`: Adjusted mappings for the renamed DTO. - `IDocumentReceiverElementService.cs` and `DocumentReceiverElementService.cs`: Updated interfaces and services to use the new DTO. - `TestDocumentReceiverElementController.cs`: Updated generic type parameters. These changes improve clarity, align naming with the domain model, and ensure consistency throughout the application.
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using EnvelopeGenerator.API.Extensions;
|
|
using EnvelopeGenerator.Application.Common.Dto;
|
|
using EnvelopeGenerator.Application.Common.Extensions;
|
|
using EnvelopeGenerator.Application.Documents.Queries;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace EnvelopeGenerator.API.Controllers;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Authorize(Policy = AuthPolicy.Receiver)]
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class SignatureController : ControllerBase
|
|
{
|
|
private readonly IMediator _mediator;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of <see cref="SignatureController"/>.
|
|
/// </summary>
|
|
public SignatureController(IMediator mediator)
|
|
{
|
|
_mediator = mediator;
|
|
}
|
|
|
|
//TODO: update to use signature query
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="envelopeKey"></param>
|
|
/// <param name="cancel"></param>
|
|
/// <returns></returns>
|
|
[Authorize(Policy = AuthPolicy.Receiver)]
|
|
[HttpGet("{envelopeKey}")]
|
|
public async Task<IActionResult> Get(string envelopeKey, CancellationToken cancel)
|
|
{
|
|
int envelopeId = User.EnvelopeId();
|
|
|
|
int receiverId = User.ReceiverId();
|
|
|
|
var doc = await _mediator.Send(new ReadDocumentQuery() { EnvelopeId = envelopeId }, cancel);
|
|
|
|
if (doc.Elements is not IEnumerable<DocReceiverElementDto> 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);
|
|
}
|
|
}
|