Refactor to use SignatureDto and SignatureService

Replaced AnnotationDto and AnnotationService with SignatureDto
and SignatureService for handling signature data. Marked
AnnotationDto and AnnotationService as obsolete.

Added the SignatureDto class to represent signature data and
introduced the SignatureService class to fetch signature data
from the API. Updated EnvelopeViewer.razor to use
SignatureService, replacing AnnotationService, and added a
debug log for retrieved signatures.

Performed general refactoring to align with the new signature
data model and functionality.
This commit is contained in:
2026-06-06 19:14:42 +02:00
parent 11a5012ab7
commit dec2b81afe
5 changed files with 43 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ namespace EnvelopeGenerator.ReceiverUI.Models;
/// <b>Difference from GDPicture:</b> GDPicture uses PDF points with <b>bottom-left</b> origin (PDF standard); Y is flipped.
/// Convert: <c>yDX = (pageHeightPt - yGD - elemHeightPt) * (100.0 / 72.0)</c>
/// </summary>
[Obsolete("Use SignatureDto with SignatureService.")]
public record AnnotationDto
{
/// <summary>Unique identifier of the annotation.</summary>

View File

@@ -0,0 +1,13 @@
namespace EnvelopeGenerator.ReceiverUI.Models;
public class SignatureDto
{
public int Id { get; set; }
public double X { get; set; }
public double Y { get; set; }
public int Page { get; set; }
}

View File

@@ -8,7 +8,7 @@
@inject IOptions<ApiOptions> AppOptions
@inject IOptions<PdfViewerOptions> PdfViewerOptions
@inject IJSRuntime JSRuntime
@inject AnnotationService AnnotService
@inject SignatureService SignatureService
@implements IAsyncDisposable
<link href="_content/DevExpress.Blazor.Themes/blazing-berry.bs5.min.css" rel="stylesheet" />
@@ -212,7 +212,9 @@ protected override async Task OnInitializedAsync() {
_errorMessage = $"Dokument konnte nicht geladen werden. HTTP Status: {statusCode}";
}
var annots = await AnnotService.GetAnnotationsAsync(EnvelopeKey);
var signatures = await SignatureService.GetAsync(EnvelopeKey);
await JSRuntime.InvokeVoidAsync("console.log", signatures);
} catch (Exception ex) {
_errorMessage = $"Fehler: {ex.Message}";

View File

@@ -14,6 +14,7 @@ namespace EnvelopeGenerator.ReceiverUI.Services;
/// <c>fake-data/annotations.json</c>. To switch to real data, update the
/// YARP route in <c>yarp.json</c> — no code change required.
/// </summary>
[Obsolete("Use SignatureService.")]
public class AnnotationService(HttpClient http, IOptions<ApiOptions> apiOptions)
{
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);

View File

@@ -0,0 +1,24 @@
using System.Net.Http.Json;
using System.Text.Json;
using EnvelopeGenerator.ReceiverUI.Models;
using EnvelopeGenerator.ReceiverUI.Options;
using Microsoft.Extensions.Options;
namespace EnvelopeGenerator.ReceiverUI.Services;
public class SignatureService(HttpClient http, IOptions<ApiOptions> apiOptions)
{
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
public async Task<IReadOnlyList<SignatureDto>> GetAsync(string envelopeKey, CancellationToken cancel = default)
{
var url = $"{apiOptions.Value.BaseUrl}/api/Signature/{Uri.EscapeDataString(envelopeKey)}";
var response = await http.GetAsync(url, cancel);
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"Failed to retrieve signatures for envelope {envelopeKey}: {response.StatusCode} {response.ReasonPhrase}");
var result = await response.Content.ReadFromJsonAsync<List<SignatureDto>>(_jsonOptions, cancel);
return result ?? [];
}
}