Refactor enum usage in codebase
Updated references from `Constants` to direct usage of `EnvelopeStatus` and `EmailTemplateType` enums. This change enhances code readability and reduces dependency on the `Constants` class. Modified properties and parameters across command classes, DTOs, repositories, and services to use the enums directly. Updated `ModifyDocStatusCommandBase`, `EnvelopeHistoryDto`, and `ResetEmailTemplateCommand` for improved clarity. Consistent updates across multiple files indicate a systematic refactoring aimed at streamlining the codebase and improving maintainability. Comments and documentation have also been revised to reflect these changes.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using EnvelopeGenerator.Application.Model;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
|
||||
@@ -11,7 +11,7 @@ public record ModifyDocStatusCommandBase : EnvelopeReceiverQueryBase
|
||||
/// <summary>
|
||||
/// Gets the current status code.
|
||||
/// </summary>
|
||||
public Constants.DocumentStatus Status => Value is null ? Constants.DocumentStatus.Created : Constants.DocumentStatus.Signed;
|
||||
public DocumentStatus Status => Value is null ? DocumentStatus.Created : DocumentStatus.Signed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display value associated with the status.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
|
||||
@@ -27,16 +27,16 @@ public record EnvelopeHistoryDto
|
||||
/// <summary>
|
||||
/// Include code of the envelope at this history point.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus Status { get; set; }
|
||||
public EnvelopeStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Type of reference for this history entry.
|
||||
/// </summary>
|
||||
public Constants.ReferenceType ReferenceType => ((int)Status).ToString().FirstOrDefault() switch
|
||||
public ReferenceType ReferenceType => ((int)Status).ToString().FirstOrDefault() switch
|
||||
{
|
||||
'1' => Constants.ReferenceType.Sender,
|
||||
'2' => Constants.ReferenceType.Receiver,
|
||||
_ => Constants.ReferenceType.System,
|
||||
'1' => ReferenceType.Sender,
|
||||
'2' => ReferenceType.Receiver,
|
||||
_ => ReferenceType.System,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Reset;
|
||||
@@ -33,8 +34,8 @@ public record ResetEmailTemplateCommand : EmailTemplateQuery, IRequest
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="Id">Die optionale ID der E-Mail-Vorlage, die zurückgesetzt werden soll.</param>
|
||||
/// <param name="Type">Der Typ der E-Mail-Vorlage, z. B. <see cref="Constants.EmailTemplateType"/> (optional).</param>
|
||||
public ResetEmailTemplateCommand(int? Id = null, Constants.EmailTemplateType? Type = null) : base(Id, Type)
|
||||
/// <param name="Type">Der Typ der E-Mail-Vorlage, z. B. <see cref="EmailTemplateType"/> (optional).</param>
|
||||
public ResetEmailTemplateCommand(int? Id = null, EmailTemplateType? Type = null) : base(Id, Type)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -46,7 +46,7 @@ public class UpdateEmailTemplateCommandHandler : IRequestHandler<UpdateEmailTemp
|
||||
var temp = await _repository.ReadOnly().Where(t => t.Id == id).FirstOrDefaultAsync(cancel);
|
||||
tempDto = _mapper.Map<EmailTemplateDto>(temp);
|
||||
}
|
||||
else if (request!.EmailTemplateQuery!.Type is Constants.EmailTemplateType type)
|
||||
else if (request!.EmailTemplateQuery!.Type is EmailTemplateType type)
|
||||
{
|
||||
var temp = await _repository.ReadOnly().Where(t => t.Name == type.ToString()).FirstOrDefaultAsync(cancel);
|
||||
tempDto = _mapper.Map<EmailTemplateDto>(temp);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace EnvelopeGenerator.Application.EmailTemplates;
|
||||
/// Die Standardkultur ist "de-DE".
|
||||
/// </summary>
|
||||
/// <param name="Id">Die eindeutige Kennung der E-Mail-Vorlage (optional).</param>
|
||||
/// <param name="Type">Der Typ der E-Mail-Vorlage, z. B. <see cref="Constants.EmailTemplateType"/> (optional). Beispiele:
|
||||
/// <param name="Type">Der Typ der E-Mail-Vorlage, z. B. <see cref="EmailTemplateType"/> (optional). Beispiele:
|
||||
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.
|
||||
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.
|
||||
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.
|
||||
@@ -19,6 +19,6 @@ namespace EnvelopeGenerator.Application.EmailTemplates;
|
||||
/// 8 - DocumentRejected_REC (Für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.
|
||||
/// 9 - DocumentRejected_REC_2 (Für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.
|
||||
/// </param>
|
||||
public record EmailTemplateQuery(int? Id = null, Constants.EmailTemplateType? Type = null)
|
||||
public record EmailTemplateQuery(int? Id = null, EmailTemplateType? Type = null)
|
||||
{
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQu
|
||||
{
|
||||
var temp = request.Id is int id
|
||||
? await _repository.ReadByIdAsync(id)
|
||||
: request.Type is Constants.EmailTemplateType type
|
||||
: request.Type is EmailTemplateType type
|
||||
? await _repository.ReadByNameAsync(type)
|
||||
: throw new InvalidOperationException("Either a valid integer ID or a valid EmailTemplateType must be provided in the request.");
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ReceiverAlreadySignedQueryHandler : IRequestHandler<ReceiverAlready
|
||||
return await _repo.Read()
|
||||
.Where(er => er.Envelope.Uuid == request.Envelope.Uuid)
|
||||
.Where(er => er.Receiver.Signature == request.Receiver.Signature)
|
||||
.Where(er => er.Envelope.History.Any(hist => hist.Status == Constants.EnvelopeStatus.DocumentSigned))
|
||||
.Where(er => er.Envelope.History.Any(hist => hist.Status == EnvelopeStatus.DocumentSigned))
|
||||
.AnyAsync(cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediatR;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Application.Model;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
@@ -16,7 +15,7 @@ public record ReadEnvelopeQuery : EnvelopeQueryBase, IRequest
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repräsentiert den Include eines Umschlags und dessen Beziehung zum Empfänger. (vgl. auch <see cref="Constants.EnvelopeStatus"/>
|
||||
/// Repräsentiert den Include eines Umschlags und dessen Beziehung zum Empfänger. (vgl. auch <see cref="EnvelopeStatus"/>
|
||||
/// Invalid (0): Ungültiger Include.
|
||||
/// EnvelopeCreated (1001): Der Umschlag wurde erstellt.
|
||||
/// EnvelopeSaved (1002): Der Umschlag wurde gespeichert.
|
||||
@@ -49,20 +48,20 @@ public record EnvelopeStatus
|
||||
/// <summary>
|
||||
/// Der minimale Statuswert, der berücksichtigt werden.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus? Min { get; init; }
|
||||
public Domain.Constants.EnvelopeStatus? Min { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Der maximale Statuswert, der berücksichtigt werden.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus? Max { get; init; }
|
||||
public Domain.Constants.EnvelopeStatus? Max { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Eine Liste von Statuswerten, die einbezogen werden.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus[]? Include { get; init; }
|
||||
public Domain.Constants.EnvelopeStatus[]? Include { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Eine Liste von Statuswerten, die ignoriert werden werden.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus[]? Ignore { get; init; }
|
||||
public Domain.Constants.EnvelopeStatus[]? Ignore { get; init; }
|
||||
}
|
||||
@@ -1,152 +1,182 @@
|
||||
using System.Text;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using System.Text;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Extensions
|
||||
namespace EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class DecodingExtensions
|
||||
{
|
||||
public static class DecodingExtensions
|
||||
/// <summary>
|
||||
/// Validates whether a given string is a correctly formatted Base-64 encoded string.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method checks the string for proper Base-64 formatting, which includes validating
|
||||
/// the length of the string (must be divisible by 4). It also checks each character to ensure
|
||||
/// it belongs to the Base-64 character set (A-Z, a-z, 0-9, '+', '/', and '=' for padding).
|
||||
/// The method ensures that padding characters ('=') only appear at the end of the string and
|
||||
/// are in a valid configuration (either one '=' at the end if the string's length % 4 is 3,
|
||||
/// or two '==' if the length % 4 is 2).
|
||||
/// </remarks>
|
||||
/// <param name="input">The Base-64 encoded string to validate.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the string is a valid Base-64 encoded string; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// string testString = "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnk=";
|
||||
/// bool isValid = IsValidBase64String(testString);
|
||||
/// Console.WriteLine(isValid); // Output: true
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static bool IsBase64String(this string input)
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates whether a given string is a correctly formatted Base-64 encoded string.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method checks the string for proper Base-64 formatting, which includes validating
|
||||
/// the length of the string (must be divisible by 4). It also checks each character to ensure
|
||||
/// it belongs to the Base-64 character set (A-Z, a-z, 0-9, '+', '/', and '=' for padding).
|
||||
/// The method ensures that padding characters ('=') only appear at the end of the string and
|
||||
/// are in a valid configuration (either one '=' at the end if the string's length % 4 is 3,
|
||||
/// or two '==' if the length % 4 is 2).
|
||||
/// </remarks>
|
||||
/// <param name="input">The Base-64 encoded string to validate.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the string is a valid Base-64 encoded string; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// string testString = "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnk=";
|
||||
/// bool isValid = IsValidBase64String(testString);
|
||||
/// Console.WriteLine(isValid); // Output: true
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static bool IsBase64String(this string input)
|
||||
// Check if the string is null or empty
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
// Check if the string is null or empty
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Replace valid base-64 padding
|
||||
input = input.Trim();
|
||||
int mod4 = input.Length % 4;
|
||||
if (mod4 > 0)
|
||||
{
|
||||
// Base-64 string lengths should be divisible by 4
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check each character to ensure it is valid base-64
|
||||
foreach (char c in input)
|
||||
{
|
||||
if (!char.IsLetterOrDigit(c) && c != '+' && c != '/' && c != '=')
|
||||
{
|
||||
// Invalid character detected
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure no invalid padding scenarios exist
|
||||
if (input.EndsWith("==") && (input.Length % 4 == 0) ||
|
||||
input.EndsWith("=") && (input.Length % 4 == 3))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return input.IndexOf('=') == -1; // No padding allowed except at the end
|
||||
}
|
||||
|
||||
public static bool TryDecode(this string encodedKey, out string[] decodedKeys)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] bytes = Convert.FromBase64String(encodedKey);
|
||||
string decodedString = Encoding.UTF8.GetString(bytes);
|
||||
decodedKeys = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
||||
return true;
|
||||
}
|
||||
catch(ArgumentNullException) { }
|
||||
catch (FormatException) { }
|
||||
catch(ArgumentException) { }
|
||||
|
||||
decodedKeys = Array.Empty<string>();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static EncodeType GetEncodeType(this string[] decodedKeys) => decodedKeys.Length switch
|
||||
// Replace valid base-64 padding
|
||||
input = input.Trim();
|
||||
int mod4 = input.Length % 4;
|
||||
if (mod4 > 0)
|
||||
{
|
||||
2 => EncodeType.EnvelopeReceiver,
|
||||
3 => long.TryParse(decodedKeys[1], out var _) ? EncodeType.EnvelopeReceiverReadOnly : EncodeType.Undefined,
|
||||
_ => EncodeType.Undefined,
|
||||
};
|
||||
|
||||
public static (string? EnvelopeUuid, string? ReceiverSignature) ParseEnvelopeReceiverId(this string[] decodedKeys)
|
||||
=> decodedKeys.GetEncodeType() == EncodeType.EnvelopeReceiver
|
||||
? (EnvelopeUuid: decodedKeys[0], ReceiverSignature: decodedKeys[1])
|
||||
: throw new InvalidOperationException("Attempted to convert a decoded other than type EnvelopeReceiver to EnvelopeReceiver.");
|
||||
|
||||
public static long ParseReadOnlyId(this string[] decodedKeys)
|
||||
=> decodedKeys.GetEncodeType() == EncodeType.EnvelopeReceiverReadOnly
|
||||
? long.Parse(decodedKeys[1])
|
||||
: throw new InvalidOperationException("Attempted to convert a decoded other than type EnvelopeReceiver to EnvelopeReceiver. ");
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature.
|
||||
/// </summary>
|
||||
/// <param name="envelopeReceiverId">The base64 encoded string containing the envelope UUID and receiver signature.</param>
|
||||
/// <returns>A tuple containing the envelope UUID and receiver signature.</returns>
|
||||
public static (string? EnvelopeUuid, string? ReceiverSignature) DecodeEnvelopeReceiverId(this string envelopeReceiverId)
|
||||
{
|
||||
if (!envelopeReceiverId.IsBase64String())
|
||||
{
|
||||
return (null, null);
|
||||
}
|
||||
byte[] bytes = Convert.FromBase64String(envelopeReceiverId);
|
||||
string decodedString = Encoding.UTF8.GetString(bytes);
|
||||
string[] parts = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
||||
|
||||
if (parts.Length > 1)
|
||||
return (EnvelopeUuid: parts[0], ReceiverSignature: parts[1]);
|
||||
else
|
||||
return (string.Empty, string.Empty);
|
||||
// Base-64 string lengths should be divisible by 4
|
||||
return false;
|
||||
}
|
||||
|
||||
public static long? DecodeEnvelopeReceiverReadOnlyId(this string envelopeReceiverReadOnlyId)
|
||||
// Check each character to ensure it is valid base-64
|
||||
foreach (char c in input)
|
||||
{
|
||||
if (!envelopeReceiverReadOnlyId.IsBase64String())
|
||||
if (!char.IsLetterOrDigit(c) && c != '+' && c != '/' && c != '=')
|
||||
{
|
||||
return null;
|
||||
// Invalid character detected
|
||||
return false;
|
||||
}
|
||||
byte[] bytes = Convert.FromBase64String(envelopeReceiverReadOnlyId);
|
||||
string decodedString = System.Text.Encoding.UTF8.GetString(bytes);
|
||||
string[] parts = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
||||
|
||||
if (parts.Length > 2)
|
||||
return long.TryParse(parts[1], out long readOnlyId) ? readOnlyId : null;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the envelope UUID from the decoded envelope receiver ID.
|
||||
/// </summary>
|
||||
/// <param name="envelopeReceiverId">The base64 encoded string to decode.</param>
|
||||
/// <returns>The envelope UUID.</returns>
|
||||
public static string? GetEnvelopeUuid(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().EnvelopeUuid;
|
||||
// Ensure no invalid padding scenarios exist
|
||||
if (input.EndsWith("==") && (input.Length % 4 == 0) ||
|
||||
input.EndsWith("=") && (input.Length % 4 == 3))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the receiver signature from the decoded envelope receiver ID.
|
||||
/// </summary>
|
||||
/// <param name="envelopeReceiverId">The base64 encoded string to decode.</param>
|
||||
/// <returns>The receiver signature.</returns>
|
||||
public static string? GetReceiverSignature(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().ReceiverSignature;
|
||||
return input.IndexOf('=') == -1; // No padding allowed except at the end
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="encodedKey"></param>
|
||||
/// <param name="decodedKeys"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryDecode(this string encodedKey, out string[] decodedKeys)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] bytes = Convert.FromBase64String(encodedKey);
|
||||
string decodedString = Encoding.UTF8.GetString(bytes);
|
||||
decodedKeys = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
||||
return true;
|
||||
}
|
||||
catch(ArgumentNullException) { }
|
||||
catch (FormatException) { }
|
||||
catch(ArgumentException) { }
|
||||
|
||||
decodedKeys = Array.Empty<string>();
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="decodedKeys"></param>
|
||||
/// <returns></returns>
|
||||
public static EncodeType GetEncodeType(this string[] decodedKeys) => decodedKeys.Length switch
|
||||
{
|
||||
2 => EncodeType.EnvelopeReceiver,
|
||||
3 => long.TryParse(decodedKeys[1], out var _) ? EncodeType.EnvelopeReceiverReadOnly : EncodeType.Undefined,
|
||||
_ => EncodeType.Undefined,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="decodedKeys"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
public static (string? EnvelopeUuid, string? ReceiverSignature) ParseEnvelopeReceiverId(this string[] decodedKeys)
|
||||
=> decodedKeys.GetEncodeType() == EncodeType.EnvelopeReceiver
|
||||
? (EnvelopeUuid: decodedKeys[0], ReceiverSignature: decodedKeys[1])
|
||||
: throw new InvalidOperationException("Attempted to convert a decoded other than type EnvelopeReceiver to EnvelopeReceiver.");
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="decodedKeys"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
public static long ParseReadOnlyId(this string[] decodedKeys)
|
||||
=> decodedKeys.GetEncodeType() == EncodeType.EnvelopeReceiverReadOnly
|
||||
? long.Parse(decodedKeys[1])
|
||||
: throw new InvalidOperationException("Attempted to convert a decoded other than type EnvelopeReceiver to EnvelopeReceiver. ");
|
||||
|
||||
/// <summary>
|
||||
/// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature.
|
||||
/// </summary>
|
||||
/// <param name="envelopeReceiverId">The base64 encoded string containing the envelope UUID and receiver signature.</param>
|
||||
/// <returns>A tuple containing the envelope UUID and receiver signature.</returns>
|
||||
public static (string? EnvelopeUuid, string? ReceiverSignature) DecodeEnvelopeReceiverId(this string envelopeReceiverId)
|
||||
{
|
||||
if (!envelopeReceiverId.IsBase64String())
|
||||
{
|
||||
return (null, null);
|
||||
}
|
||||
byte[] bytes = Convert.FromBase64String(envelopeReceiverId);
|
||||
string decodedString = Encoding.UTF8.GetString(bytes);
|
||||
string[] parts = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
||||
|
||||
if (parts.Length > 1)
|
||||
return (EnvelopeUuid: parts[0], ReceiverSignature: parts[1]);
|
||||
else
|
||||
return (string.Empty, string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="envelopeReceiverReadOnlyId"></param>
|
||||
/// <returns></returns>
|
||||
public static long? DecodeEnvelopeReceiverReadOnlyId(this string envelopeReceiverReadOnlyId)
|
||||
{
|
||||
if (!envelopeReceiverReadOnlyId.IsBase64String())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] bytes = Convert.FromBase64String(envelopeReceiverReadOnlyId);
|
||||
string decodedString = System.Text.Encoding.UTF8.GetString(bytes);
|
||||
string[] parts = decodedString.Split(new string[] { "::" }, StringSplitOptions.None);
|
||||
|
||||
if (parts.Length > 2)
|
||||
return long.TryParse(parts[1], out long readOnlyId) ? readOnlyId : null;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the envelope UUID from the decoded envelope receiver ID.
|
||||
/// </summary>
|
||||
/// <param name="envelopeReceiverId">The base64 encoded string to decode.</param>
|
||||
/// <returns>The envelope UUID.</returns>
|
||||
public static string? GetEnvelopeUuid(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().EnvelopeUuid;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the receiver signature from the decoded envelope receiver ID.
|
||||
/// </summary>
|
||||
/// <param name="envelopeReceiverId">The base64 encoded string to decode.</param>
|
||||
/// <returns>The receiver signature.</returns>
|
||||
public static string? GetReceiverSignature(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().ReceiverSignature;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using MediatR;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
@@ -15,5 +15,5 @@ namespace EnvelopeGenerator.Application.Histories.Queries;
|
||||
public record ReadHistoryQuery(
|
||||
[Required]
|
||||
int EnvelopeId,
|
||||
Constants.EnvelopeStatus? Status = null,
|
||||
EnvelopeStatus? Status = null,
|
||||
bool? OnlyLast = true) : IRequest<IEnumerable<EnvelopeHistoryDto>>;
|
||||
@@ -1,6 +1,6 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
@@ -17,7 +17,7 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, l
|
||||
/// <param name="userReference"></param>
|
||||
/// <param name="status"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null);
|
||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -28,5 +28,5 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, l
|
||||
/// <param name="withSender"></param>
|
||||
/// <param name="withReceiver"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false);
|
||||
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
@@ -84,7 +84,7 @@ public interface IEnvelopeReceiverRepository : ICRUDRepository<EnvelopeReceiver,
|
||||
/// <param name="max_status"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses);
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, params EnvelopeStatus[] ignore_statuses);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
@@ -39,5 +39,5 @@ public interface IEnvelopeRepository : ICRUDRepository<Envelope, int>
|
||||
/// <param name="max_status"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses);
|
||||
Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, params EnvelopeStatus[] ignore_statuses);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Contracts;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface IEnvelopeMailService : IEmailOutService
|
||||
/// <param name="tempType"></param>
|
||||
/// <param name="optionalPlaceholders"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataResult<int>> SendAsync(EnvelopeReceiverDto envelopeReceiverDto, Constants.EmailTemplateType tempType, Dictionary<string, object>? optionalPlaceholders = null);
|
||||
Task<DataResult<int>> SendAsync(EnvelopeReceiverDto envelopeReceiverDto, EmailTemplateType tempType, Dictionary<string, object>? optionalPlaceholders = null);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -122,7 +122,7 @@ public interface IEnvelopeReceiverService : IBasicCRUDService<EnvelopeReceiverDt
|
||||
/// <param name="receiverQuery"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, ReadEnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params Constants.EnvelopeStatus[] ignore_statuses);
|
||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, ReadEnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params EnvelopeStatus[] ignore_statuses);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
@@ -41,5 +41,5 @@ public interface IEnvelopeService : IBasicCRUDService<EnvelopeDto, Envelope, int
|
||||
/// <param name="max_status"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses);
|
||||
Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId, Domain.Constants.EnvelopeStatus? min_status = null, Domain.Constants.EnvelopeStatus? max_status = null, params Domain.Constants.EnvelopeStatus[] ignore_statuses);
|
||||
}
|
||||
@@ -3,10 +3,10 @@ using DigitalData.Core.Application;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Services;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
using DigitalData.Core.Application;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Services;
|
||||
|
||||
|
||||
@@ -5,15 +5,13 @@ using DigitalData.EmailProfilerDispatcher.Abstraction.Services;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Application.Configurations;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Services;
|
||||
|
||||
@@ -148,7 +146,7 @@ public async Task<DataResult<int>> SendAsync(EnvelopeReceiverReadOnlyDto dto, Di
|
||||
{
|
||||
var tempSerResult = await _tempService.ReadByNameAsync(EmailTemplateType.DocumentShared);
|
||||
if (tempSerResult.IsFailed)
|
||||
return tempSerResult.ToFail<int>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"The email cannot send because '{Constants.EmailTemplateType.DocumentShared}' template cannot found.");
|
||||
return tempSerResult.ToFail<int>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"The email cannot send because '{EmailTemplateType.DocumentShared}' template cannot found.");
|
||||
var temp = tempSerResult.Data;
|
||||
|
||||
var mail = new EmailOutCreateDto()
|
||||
|
||||
@@ -239,7 +239,7 @@ public class EnvelopeReceiverService : BasicCRUDService<IEnvelopeReceiverReposit
|
||||
/// <param name="receiverQuery"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, ReadEnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params Constants.EnvelopeStatus[] ignore_statuses)
|
||||
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, ReadEnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params EnvelopeStatus[] ignore_statuses)
|
||||
{
|
||||
var er_list = await _repository.ReadByUsernameAsync(username: username, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses);
|
||||
|
||||
@@ -249,7 +249,7 @@ public class EnvelopeReceiverService : BasicCRUDService<IEnvelopeReceiverReposit
|
||||
if (envelopeQuery?.Uuid is string uuid)
|
||||
er_list = er_list.Where(er => er.Envelope?.Uuid == uuid);
|
||||
|
||||
if (envelopeQuery?.Status?.Include?.FirstOrDefault() is Constants.EnvelopeStatus status)
|
||||
if (envelopeQuery?.Status?.Include?.FirstOrDefault() is Domain.Constants.EnvelopeStatus status)
|
||||
er_list = er_list.Where(er => er.Envelope?.Status == status);
|
||||
|
||||
if(receiverQuery?.Id is int id)
|
||||
|
||||
@@ -5,9 +5,6 @@ using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
using System.Reflection.Metadata;
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Services;
|
||||
|
||||
@@ -70,7 +67,7 @@ public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto
|
||||
/// <param name="max_status"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses)
|
||||
public async Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId, Domain.Constants.EnvelopeStatus? min_status = null, Domain.Constants.EnvelopeStatus? max_status = null, params Domain.Constants.EnvelopeStatus[] ignore_statuses)
|
||||
{
|
||||
var users = await _repository.ReadByUserAsync(userId: userId, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses);
|
||||
var readDto = _mapper.Map<IEnumerable<EnvelopeDto>>(users);
|
||||
|
||||
Reference in New Issue
Block a user