refactor: remove CreateEnvelopeReceiverResponse
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
using EnvelopeGenerator.Application.Dto;
|
||||||
using EnvelopeGenerator.Application.Envelopes.Commands;
|
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record CreateEnvelopeReceiverResponse : CreateEnvelopeResponse
|
public record CreateEnvelopeReceiverResponse : EnvelopeDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ public class MappingProfile : Profile
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<Envelope, CreateEnvelopeResponse>();
|
|
||||||
CreateMap<Receiver, ReceiverReadDto>();
|
CreateMap<Receiver, ReceiverReadDto>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
using EnvelopeGenerator.Application.Dto;
|
||||||
|
using EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@@ -16,7 +17,7 @@ public record CreateEnvelopeCommand(
|
|||||||
[Required] string Title,
|
[Required] string Title,
|
||||||
[Required] string Message,
|
[Required] string Message,
|
||||||
bool TFAEnabled = false
|
bool TFAEnabled = false
|
||||||
) : IRequest<CreateEnvelopeResponse?>
|
) : IRequest<EnvelopeDto?>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Id of receiver
|
/// Id of receiver
|
||||||
@@ -24,9 +25,4 @@ public record CreateEnvelopeCommand(
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[BindNever]
|
[BindNever]
|
||||||
public int? UserId { get; set; }
|
public int? UserId { get; set; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public record CreateEnvelopeResponse : ReadEnvelopeResponse;
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||||
|
using EnvelopeGenerator.Application.Dto;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
@@ -7,7 +8,7 @@ namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeCommand, CreateEnvelopeResponse?>
|
public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeCommand, EnvelopeDto?>
|
||||||
{
|
{
|
||||||
private readonly IEnvelopeExecutor _envelopeExecutor;
|
private readonly IEnvelopeExecutor _envelopeExecutor;
|
||||||
|
|
||||||
@@ -30,12 +31,12 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
|
|||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<CreateEnvelopeResponse?> Handle(CreateEnvelopeCommand request, CancellationToken cancellationToken)
|
public async Task<EnvelopeDto?> Handle(CreateEnvelopeCommand request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
int userId = request.UserId ?? throw new InvalidOperationException("UserId cannot be null when creating an envelope.");
|
int userId = request.UserId ?? throw new InvalidOperationException("UserId cannot be null when creating an envelope.");
|
||||||
|
|
||||||
var envelope = await _envelopeExecutor.CreateEnvelopeAsync(userId, request.Title, request.Message, request.TFAEnabled, cancellationToken);
|
var envelope = await _envelopeExecutor.CreateEnvelopeAsync(userId, request.Title, request.Message, request.TFAEnabled, cancellationToken);
|
||||||
|
|
||||||
return _mapper.Map<CreateEnvelopeResponse>(envelope);
|
return _mapper.Map<EnvelopeDto>(envelope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
using EnvelopeGenerator.Domain;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Repräsentiert die Antwort für das Lesen eines Umschlags.
|
|
||||||
/// </summary>
|
|
||||||
public record ReadEnvelopeResponse
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Die eindeutige Kennung des Umschlags.
|
|
||||||
/// </summary>
|
|
||||||
public int Id { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Die Kennung des Benutzers, der den Umschlag erstellt hat.
|
|
||||||
/// </summary>
|
|
||||||
public int UserId { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Der Status des Umschlags als numerischer Wert.
|
|
||||||
/// </summary>
|
|
||||||
public int Status { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Die universelle eindeutige Kennung (UUID) des Umschlags.
|
|
||||||
/// </summary>
|
|
||||||
public string Uuid { get; init; } = default!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Eine optionale Nachricht, die mit dem Umschlag verknüpft ist.
|
|
||||||
/// </summary>
|
|
||||||
public string? Message { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Das Datum und die Uhrzeit, wann der Umschlag hinzugefügt wurde.
|
|
||||||
/// </summary>
|
|
||||||
public DateTime AddedWhen { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Das Datum und die Uhrzeit, wann der Umschlag zuletzt geändert wurde (falls vorhanden).
|
|
||||||
/// </summary>
|
|
||||||
public DateTime? ChangedWhen { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ein optionaler Titel des Umschlags.
|
|
||||||
/// </summary>
|
|
||||||
public string? Title { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Die Sprache, die mit dem Umschlag verknüpft ist.
|
|
||||||
/// </summary>
|
|
||||||
public string Language { get; init; } = default!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gibt an, ob die Zwei-Faktor-Authentifizierung (TFA) aktiviert ist.
|
|
||||||
/// </summary>
|
|
||||||
public bool TFAEnabled { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Das Benutzerobjekt, das mit dem Umschlag verknüpft ist.
|
|
||||||
/// </summary>
|
|
||||||
public DigitalData.UserManager.Domain.Entities.User User { get; init; } = default!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gibt den Namen des Status zurück, der dem numerischen Statuswert entspricht.
|
|
||||||
/// </summary>
|
|
||||||
public string StatusName => ((Constants.EnvelopeStatus)Status).ToString();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user