Add signature submission feature and pipeline updates
Introduced a new feature for submitting signatures, including backend and frontend changes. Added `SignatureSubmitDto` and `SubmitAsync` in `SignatureService` to handle signature data submission. Implemented a new `Submit` endpoint in `SignatureController` to validate and process signature payloads. Updated pipeline behaviors to include `SaveSignatureBehavior` and adjusted the execution order. Enhanced query logic in `EnvelopeReceiverResolutionBehavior` and `SaveSignatureBehavior` to align with the updated data model. Refactored `EGDbContext` to improve trigger handling and logging. Updated `ReceiverSignedPage.razor` to integrate `SignatureService` and handle submission errors gracefully. Adjusted application URLs in `launchSettings.json` and added new database triggers in `appsettings.json`.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
namespace EnvelopeGenerator.Server.Client.Models;
|
||||
|
||||
public sealed record SignatureSubmitDto
|
||||
{
|
||||
public required int Id { get; init; }
|
||||
public required string DataUrl { get; init; }
|
||||
public required string FullName { get; init; }
|
||||
public string? Position { get; init; }
|
||||
public required string Place { get; init; }
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using EnvelopeGenerator.Application.Common.Dto;
|
||||
using EnvelopeGenerator.Server.Client.Models;
|
||||
|
||||
namespace EnvelopeGenerator.Server.Client.Services;
|
||||
@@ -21,4 +22,32 @@ public class SignatureService(IHttpClientFactory httpClientFactory)
|
||||
var result = await response.Content.ReadFromJsonAsync<List<SignatureDto>>(_jsonOptions, cancel);
|
||||
return result ?? [];
|
||||
}
|
||||
|
||||
public async Task SubmitAsync(string envelopeKey, IEnumerable<SignatureSubmitDto> signatures, CancellationToken cancel = default)
|
||||
{
|
||||
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||
|
||||
var payload = signatures
|
||||
.Select(signature => new Signature
|
||||
{
|
||||
Id = signature.Id,
|
||||
DataUrl = signature.DataUrl,
|
||||
FullName = signature.FullName,
|
||||
Position = signature.Position,
|
||||
Place = signature.Place
|
||||
})
|
||||
.ToList();
|
||||
|
||||
var response = await http.PostAsJsonAsync(
|
||||
$"/api/Signature/submit/{Uri.EscapeDataString(envelopeKey)}",
|
||||
payload,
|
||||
cancel);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var body = await response.Content.ReadAsStringAsync(cancel);
|
||||
throw new HttpRequestException(
|
||||
$"Failed to submit signature for envelope {envelopeKey}: {(int)response.StatusCode} {response.StatusCode} - {body}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user