Refactor envelope handling and introduce new queries
Restructured the `CreateEnvelope` functionality by moving the `CreateEnvelopeCommand` and related DTOs to a new namespace. Der `EnvelopeReceiverController` wurde aktualisiert, um diese Änderungen widerzuspiegeln, und die Parameter wurden zur besseren Übersichtlichkeit umbenannt. Es wurden neue Abfragesätze für das Lesen von Umschlag-Empfängern und definierte Antwortstrukturen eingeführt, wodurch die Gesamtorganisation und die Wartbarkeit der Codebasis verbessert wurden. Übersetzt mit DeepL.com (kostenlose Version)
This commit is contained in:
parent
261d1b3db9
commit
b3a2e1559a
@ -1,7 +1,7 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||||
|
|
||||||
#region DTOs
|
#region DTOs
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -21,7 +21,7 @@ public record Signature([Required] int X, [Required] int Y, [Required] int Page)
|
|||||||
/// <param name="PhoneNumber">Sollte mit Vorwahl geschrieben werden</param>
|
/// <param name="PhoneNumber">Sollte mit Vorwahl geschrieben werden</param>
|
||||||
public record ReceiverGetOrCreateDto([Required] IEnumerable<Signature> Signatures, string? Name = null, string? PhoneNumber = null)
|
public record ReceiverGetOrCreateDto([Required] IEnumerable<Signature> Signatures, string? Name = null, string? PhoneNumber = null)
|
||||||
{
|
{
|
||||||
private string _emailAddress;
|
private string _emailAddress = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// E-Mail-Adresse des Empfängers.
|
/// E-Mail-Adresse des Empfängers.
|
||||||
@ -50,14 +50,3 @@ public record CreateEnvelopeCommand(
|
|||||||
int ContractType = (int)Common.Constants.ContractType.Contract,
|
int ContractType = (int)Common.Constants.ContractType.Contract,
|
||||||
bool TFAEnabled = false
|
bool TFAEnabled = false
|
||||||
) : IRequest;
|
) : IRequest;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handler für den CreateEnvelopeCommand.
|
|
||||||
/// </summary>
|
|
||||||
public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeCommand>
|
|
||||||
{
|
|
||||||
public Task<Unit> Handle(CreateEnvelopeCommand request, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||||
|
using EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.EnvelopeReceivers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stellt eine Abfrage zum Lesen eines Envelope-Empfängers dar.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="MinStatus"></param>
|
||||||
|
/// <param name="MaxStatus"></param>
|
||||||
|
/// <param name="IgnoreStatus"></param>
|
||||||
|
/// <param name="Receiver"></param>
|
||||||
|
public record EnvelopeReceiverQuery(
|
||||||
|
int? MinStatus = null,
|
||||||
|
int? MaxStatus = null,
|
||||||
|
int[]? IgnoreStatus = null);
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||||
|
using EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries.Read;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stellt eine Abfrage zum Lesen eines Envelope-Empfängers dar.
|
||||||
|
/// </summary>
|
||||||
|
public record ReadEnvelopeReceiverQuery : EnvelopeReceiverQuery, IRequest<ReadEnvelopeReceiverResponse>
|
||||||
|
{
|
||||||
|
public ReadEnvelopeQuery? Envelope { get; init; }
|
||||||
|
|
||||||
|
public ReadReceiverQuery? Receiver { get; init; }
|
||||||
|
};
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes;
|
||||||
|
using EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries.Read;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stellt eine Antwort auf die Abfrage zum Lesen eines Envelope-Empfängers dar.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Receiver">Der angeforderte Empfänger.</param>
|
||||||
|
public record ReadEnvelopeReceiverResponse(int UserId, int Status)
|
||||||
|
{
|
||||||
|
[NotMapped]
|
||||||
|
public (int Envelope, int Receiver) Id => (Envelope: EnvelopeId, Receiver: ReceiverId);
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int EnvelopeId { get; init; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int ReceiverId { get; init; }
|
||||||
|
|
||||||
|
public int Sequence { get; init; }
|
||||||
|
|
||||||
|
[TemplatePlaceholder("[NAME_RECEIVER]")]
|
||||||
|
public string? Name { get; init; }
|
||||||
|
|
||||||
|
public string? JobTitle { get; init; }
|
||||||
|
|
||||||
|
public string? CompanyName { get; init; }
|
||||||
|
|
||||||
|
public string? PrivateMessage { get; init; }
|
||||||
|
|
||||||
|
public DateTime AddedWhen { get; init; }
|
||||||
|
|
||||||
|
public DateTime? ChangedWhen { get; init; }
|
||||||
|
|
||||||
|
public bool HasPhoneNumber { get; init; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public required ReadReceiverResponse Envelope { get; init; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public required ReadReceiverResponse Receiver { get; init; }
|
||||||
|
}
|
||||||
16
EnvelopeGenerator.Application/Envelopes/EnvelopeQuery.cs
Normal file
16
EnvelopeGenerator.Application/Envelopes/EnvelopeQuery.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Envelopes;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repräsentiert eine Abfrage für Umschläge.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Id">Die eindeutige Kennung des Umschlags.</param>
|
||||||
|
/// <param name="UserId">Die Kennung des Benutzers, der den Umschlag erstellt hat.</param>
|
||||||
|
/// <param name="Status">Der Status des Umschlags.</param>
|
||||||
|
/// <param name="Uuid">Die universell eindeutige Kennung des Umschlags.</param>
|
||||||
|
public record EnvelopeQuery(
|
||||||
|
int? Id = null,
|
||||||
|
int? UserId = null,
|
||||||
|
int? Status = null,
|
||||||
|
string? Uuid = null) : IRequest;
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||||
|
|
||||||
|
public record ReadEnvelopeQuery : EnvelopeQuery
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||||
|
|
||||||
|
public record ReadReceiverQuery : ReceiverQuery
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||||
|
|
||||||
|
public record ReadReceiverResponse
|
||||||
|
{
|
||||||
|
}
|
||||||
3
EnvelopeGenerator.Application/Receivers/ReceiverQuery.cs
Normal file
3
EnvelopeGenerator.Application/Receivers/ReceiverQuery.cs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Receivers;
|
||||||
|
|
||||||
|
public record ReceiverQuery(int? Id = null, string? EmailAddress = null, string? Signature = null);
|
||||||
@ -1,7 +1,6 @@
|
|||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts.Services;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||||
using EnvelopeGenerator.Common.My.Resources;
|
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@ -104,7 +103,7 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Datenübertragungsobjekt mit Informationen zu Umschlägen, Empfängern und Unterschriften.
|
/// Datenübertragungsobjekt mit Informationen zu Umschlägen, Empfängern und Unterschriften.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="envelope"></param>
|
/// <param name="createEnvelopeQuery"></param>
|
||||||
/// <param name="cancellationToken">Token to cancel the operation</param>
|
/// <param name="cancellationToken">Token to cancel the operation</param>
|
||||||
/// <returns>HTTP-Antwort</returns>
|
/// <returns>HTTP-Antwort</returns>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
@ -145,9 +144,9 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
|||||||
/// <response code="500">Es handelt sich um einen unerwarteten Fehler. Die Protokolle sollten überprüft werden.</response>
|
/// <response code="500">Es handelt sich um einen unerwarteten Fehler. Die Protokolle sollten überprüft werden.</response>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> CreateAsync([FromBody] CreateEnvelopeCommand envelope, CancellationToken cancellationToken)
|
public async Task<IActionResult> CreateAsync([FromBody] CreateEnvelopeCommand createEnvelopeQuery, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await _mediator.Send(envelope, cancellationToken);
|
await _mediator.Send(createEnvelopeQuery, cancellationToken);
|
||||||
return Accepted();
|
return Accepted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user