Add envelope creation functionality and SQL integration
- Updated `EnvelopeGenerator.Application.csproj` to include `Microsoft.Data.SqlClient` package. - Refactored `CreateEnvelopeReceiverCommand` to inherit from `CreateEnvelopeCommand`. - Enhanced `CreateEnvelopeSQL` with a SQL script for envelope creation. - Introduced `CreateEnvelopeCommand` to encapsulate envelope creation data. - Added `CreateEnvelopeCommandHandler` to process commands and interact with the database. - Created `CreateEnvelopeResponse` class for handling responses from envelope creation.
This commit is contained in:
parent
7cffc3f7bc
commit
d46aa6e2b8
@ -20,6 +20,7 @@
|
|||||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.0.0" />
|
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.0.0" />
|
||||||
<PackageReference Include="MediatR" Version="12.5.0" />
|
<PackageReference Include="MediatR" Version="12.5.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
|
||||||
|
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4" />
|
||||||
<PackageReference Include="Otp.NET" Version="1.4.0" />
|
<PackageReference Include="Otp.NET" Version="1.4.0" />
|
||||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using MediatR;
|
using EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
|
using MediatR;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||||
@ -17,7 +18,7 @@ public record CreateEnvelopeReceiverCommand(
|
|||||||
[Required] DocumentCreateCommand Document,
|
[Required] DocumentCreateCommand Document,
|
||||||
[Required] IEnumerable<ReceiverGetOrCreateCommand> Receivers,
|
[Required] IEnumerable<ReceiverGetOrCreateCommand> Receivers,
|
||||||
bool TFAEnabled = false
|
bool TFAEnabled = false
|
||||||
) : IRequest;
|
) : CreateEnvelopeCommand(Title, Message, TFAEnabled), IRequest;
|
||||||
|
|
||||||
#region DTOs
|
#region DTOs
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
using MediatR;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Befehl zur Erstellung eines Umschlags.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Title">Der Titel des Umschlags. Dies ist ein Pflichtfeld.</param>
|
||||||
|
/// <param name="Message">Die Nachricht, die im Umschlag enthalten sein soll. Dies ist ein Pflichtfeld.</param>
|
||||||
|
/// <param name="TFAEnabled">Gibt an, ob die Zwei-Faktor-Authentifizierung für den Umschlag aktiviert ist. Standardmäßig false.</param>
|
||||||
|
public record CreateEnvelopeCommand(
|
||||||
|
[Required] string Title,
|
||||||
|
[Required] string Message,
|
||||||
|
bool TFAEnabled = false
|
||||||
|
) : IRequest<CreateEnvelopeResponse?>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Id of receiver
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
};
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeCommand, CreateEnvelopeResponse?>
|
||||||
|
{
|
||||||
|
private readonly ISQLExecutor<Envelope> _sqlExecutor;
|
||||||
|
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sqlExecutor"></param>
|
||||||
|
/// <param name="mapper"></param>
|
||||||
|
public CreateEnvelopeCommandHandler(ISQLExecutor<Envelope> sqlExecutor, IMapper mapper)
|
||||||
|
{
|
||||||
|
_sqlExecutor = sqlExecutor;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<CreateEnvelopeResponse?> Handle(CreateEnvelopeCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
object[] parameters = new object[]
|
||||||
|
{
|
||||||
|
new SqlParameter("@UserId", request.UserId),
|
||||||
|
new SqlParameter("@Title", request.Title),
|
||||||
|
new SqlParameter("@TfaEnabled", request.TFAEnabled ? 1 : 0),
|
||||||
|
new SqlParameter("@Message", request.Message)
|
||||||
|
};
|
||||||
|
|
||||||
|
var envelope = await _sqlExecutor.Execute<CreateEnvelopeSQL>(cancellationToken, parameters).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
return _mapper.Map<CreateEnvelopeResponse>(envelope);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class CreateEnvelopeResponse
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -10,5 +11,19 @@ public class CreateEnvelopeSQL : ISQL<Envelope>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Raw => string.Empty;
|
public string Raw => @"
|
||||||
|
USE [DD_ECM];
|
||||||
|
DECLARE @OUT_UID varchar(36);
|
||||||
|
|
||||||
|
EXEC [dbo].[PRSIG_API_CREATE_ENVELOPE]
|
||||||
|
@USER_ID = @UserId,
|
||||||
|
@TITLE = @Title,
|
||||||
|
@TFAEnabled = @TfaEnabled,
|
||||||
|
@MESSAGE = @Message,
|
||||||
|
@OUT_UID = @OUT_UID OUTPUT;
|
||||||
|
|
||||||
|
SELECT *
|
||||||
|
FROM [dbo].[TBSIG_ENVELOPE]
|
||||||
|
WHERE [ENVELOPE_UUID] = @OUT_UID;
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user