Added new optional properties to `CreateEnvelopeCommand` for detailed configuration, including `EnvelopeId`, `Language`, `UseAccessCode`, and expiration settings. Introduced `ResolveEnvelopeSettingsAsync` to centralize settings resolution logic. Updated `CreateEnvelopeCommandHandler` to handle new properties and improve envelope creation/update flow. Added `EnvelopeSettings` record for structured settings management. Enhanced SQL update logic with `UseSQLExecutor` support. Improved handling of language resolution, reminders, and expiration rules.
141 lines
4.1 KiB
C#
141 lines
4.1 KiB
C#
using EnvelopeGenerator.Application.Common.Dto;
|
|
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
|
|
using MediatR;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
|
|
|
/// <summary>
|
|
/// Befehl zur Erstellung eines Umschlags.
|
|
/// </summary>
|
|
public record CreateEnvelopeCommand : IRequest<EnvelopeDto?>
|
|
{
|
|
/// <summary>
|
|
/// Optionale Umschlag-ID fuer Aktualisierungsvorgaenge.
|
|
/// </summary>
|
|
public int? EnvelopeId { get; init; }
|
|
|
|
/// <summary>
|
|
/// Kennung des ausgewaehlten Umschlagtyps (Vorlage).
|
|
/// </summary>
|
|
public int? EnvelopeTypeId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Sprachcode fuer Umschlaginhalt und Benachrichtigungen.
|
|
/// </summary>
|
|
public string? Language { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gibt an, ob der Zugriffscode fuer Empfaenger aktiviert ist.
|
|
/// </summary>
|
|
public bool? UseAccessCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// Zertifizierungstyp fuer den Signaturprozess.
|
|
/// </summary>
|
|
public int? CertificationType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Finale E-Mail-Einstellung fuer den Ersteller.
|
|
/// </summary>
|
|
public int? FinalEmailToCreator { get; set; }
|
|
|
|
/// <summary>
|
|
/// Finale E-Mail-Einstellung fuer die Empfaenger.
|
|
/// </summary>
|
|
public int? FinalEmailToReceivers { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gibt an, ob Erinnerungs-E-Mails aktiviert sind.
|
|
/// </summary>
|
|
public bool? SendReminderEmails { get; set; }
|
|
|
|
/// <summary>
|
|
/// Anzahl der Tage bis zur ersten Erinnerung.
|
|
/// </summary>
|
|
public int? FirstReminderDays { get; set; }
|
|
|
|
/// <summary>
|
|
/// Intervall in Tagen zwischen Erinnerungs-E-Mails.
|
|
/// </summary>
|
|
public int? ReminderIntervalDays { get; set; }
|
|
|
|
/// <summary>
|
|
/// Anzahl der Tage bis zum Ablauf des Umschlags.
|
|
/// </summary>
|
|
public int? ExpiresWhenDays { get; set; }
|
|
|
|
/// <summary>
|
|
/// Anzahl der Tage vor Ablauf, ab denen gewarnt wird.
|
|
/// </summary>
|
|
public int? ExpiresWarningWhenDays { get; set; }
|
|
|
|
/// <summary>
|
|
/// Der Titel des Umschlags. Dies ist ein Pflichtfeld.
|
|
/// </summary>
|
|
public string? Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// Die Nachricht, die im Umschlag enthalten sein soll. Dies ist ein Pflichtfeld.
|
|
/// </summary>
|
|
public string? Message { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gibt an, ob die Zwei-Faktor-Authentifizierung für den Umschlag aktiviert ist. Standardmäßig false.
|
|
/// </summary>
|
|
public bool TFAEnabled { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Gibt an, ob der Umschlag nach dem Speichern sofort versendet werden soll.
|
|
/// </summary>
|
|
public bool Send { get; init; }
|
|
|
|
/// <summary>
|
|
/// Optionaler PDF-Dokumentinhalt als Base64.
|
|
/// </summary>
|
|
public CreateEnvelopeDocumentDto? Document { get; init; }
|
|
|
|
/// <summary>
|
|
/// Empfaengerliste inklusive optionaler Signaturfeld-Koordinaten.
|
|
/// </summary>
|
|
public List<CreateEnvelopeReceiverDto> Receivers { get; init; } = new();
|
|
|
|
/// <summary>
|
|
/// ID des Absenders
|
|
/// </summary>
|
|
internal int UserId { get; private set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
/// <returns></returns>
|
|
public CreateEnvelopeCommand WithAuth(int userId)
|
|
{
|
|
UserId = userId;
|
|
return this;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines which component is used for envelope processing.
|
|
/// When <c>true</c>, processing is delegated to <see cref="IEnvelopeExecutor"/>;
|
|
/// when <c>false</c>, <see cref="IRepository{Envelope}"/> is used instead.
|
|
/// Note: <see cref="IRepository{Envelope}"/> should only be used in testing scenarios.
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
[NotMapped]
|
|
public bool UseSQLExecutor { get; set; } = true;
|
|
}
|
|
|
|
public record CreateEnvelopeDocumentDto(string DataAsBase64);
|
|
|
|
public record CreateEnvelopeFieldDto(double X, double Y, int Page);
|
|
|
|
public record CreateEnvelopeReceiverDto(
|
|
string EmailAddress,
|
|
string? Name,
|
|
string? PhoneNumber,
|
|
List<CreateEnvelopeFieldDto> Fields);
|