Merge branch 'master' of http://git.dd:3000/AppStd/EnvelopeGenerator
# Conflicts: # EnvelopeGenerator.Server/EnvelopeGenerator.Server/Components/Pages/ReceiverSignedPage.razor # EnvelopeGenerator.Server/EnvelopeGenerator.Server/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