- Switch EnvelopeController and ReceiverController to MediatR for all operations - Encapsulate UserId in CreateEnvelopeCommand via Authorize() method - Change CreateEnvelopeCommand binding to [FromBody] - Add CancellationToken support to EnvelopeReceiverController - Remove obsolete CRUD logic from ReceiverController; now only supports GET via MediatR - Clean up unused dependencies and update controller summaries for clarity
58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
using DigitalData.Core.Abstraction.Application.Repository;
|
|
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>
|
|
/// Der Titel des Umschlags. Dies ist ein Pflichtfeld.
|
|
/// </summary>
|
|
[Required]
|
|
public required string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// Die Nachricht, die im Umschlag enthalten sein soll. Dies ist ein Pflichtfeld.
|
|
/// </summary>
|
|
[Required]
|
|
public required 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>
|
|
/// ID des Absenders
|
|
/// </summary>
|
|
internal int UserId { get; private set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
/// <returns></returns>
|
|
public bool Authorize(int userId)
|
|
{
|
|
UserId = userId;
|
|
return true;
|
|
}
|
|
|
|
/// <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;
|
|
} |