Replaced all instances of `EnvelopeTypeId` (int/int?) with `Type` (EnvelopeType/EnvelopeType?) across the codebase to improve type safety and readability. Updated affected properties, methods, and logic in DTOs, commands, handlers, and Razor components. Introduced conditional compilation to handle differences between .NET and .NET Framework where necessary. Removed obsolete helper methods for `EnvelopeTypeId`. This refactor ensures consistent use of the strongly-typed `EnvelopeType` enum, reducing the risk of invalid values and aligning with best practices.
155 lines
4.5 KiB
C#
155 lines
4.5 KiB
C#
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using EnvelopeGenerator.Application.Common.Dto;
|
|
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
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 EnvelopeType? Type { 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>
|
|
/// 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;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="DataAsBase64"></param>
|
|
public record CreateEnvelopeDocumentDto(string DataAsBase64);
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="X"></param>
|
|
/// <param name="Y"></param>
|
|
/// <param name="Page"></param>
|
|
public record CreateEnvelopeFieldDto(double X, double Y, int Page);
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="EmailAddress"></param>
|
|
/// <param name="Name"></param>
|
|
/// <param name="PhoneNumber"></param>
|
|
/// <param name="Fields"></param>
|
|
public record CreateEnvelopeReceiverDto(
|
|
string EmailAddress,
|
|
string? Name,
|
|
string? PhoneNumber,
|
|
List<CreateEnvelopeFieldDto> Fields);
|