From c5c040fb1508114982dd17a694a6a59fd0ced32b Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 1 Sep 2025 11:04:40 +0200 Subject: [PATCH] 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. --- .../Commands/ModifyDocStatusCommandBase.cs | 4 +- .../Dto/EnvelopeHistory/EnvelopeHistoryDto.cs | 12 +- .../Reset/ResetEmailTemplateCommand.cs | 5 +- .../UpdateEmailTemplateCommandHandler.cs | 2 +- .../EmailTemplates/EmailTemplateQuery.cs | 6 +- .../Read/ReadEmailTemplateQueryHandler.cs | 2 +- .../Queries/ReceiverAlreadySignedQuery.cs | 2 +- .../Envelopes/Queries/ReadEnvelopeQuery.cs | 11 +- .../Extensions/DecodingExtensions.cs | 290 ++++++++++-------- .../Histories/Queries/ReadHistoryQuery.cs | 4 +- .../Repositories/IEmailTemplateRepository.cs | 2 +- .../IEnvelopeHistoryRepository.cs | 6 +- .../IEnvelopeReceiverRepository.cs | 4 +- .../Repositories/IEnvelopeRepository.cs | 4 +- .../Services/IEmailTemplateService.cs | 2 +- .../Services/IEnvelopeHistoryService.cs | 2 +- .../Services/IEnvelopeMailService.cs | 4 +- .../Services/IEnvelopeReceiverService.cs | 2 +- .../Interfaces/Services/IEnvelopeService.cs | 4 +- .../Services/EmailTemplateService.cs | 2 +- .../Services/EnvelopeHistoryService.cs | 2 +- .../Services/EnvelopeMailService.cs | 6 +- .../Services/EnvelopeReceiverService.cs | 4 +- .../Services/EnvelopeService.cs | 5 +- .../Jobs/FinalizeDocument/ReportItem.vb | 2 +- .../Models/EmailData.vb | 6 +- .../Models/EnvelopeModel.vb | 2 +- .../Models/HistoryModel.vb | 2 +- .../Services/EmailService.vb | 14 +- EnvelopeGenerator.Domain/Entities/Envelope.cs | 8 +- .../Entities/EnvelopeHistory.cs | 2 +- .../Controllers/EnvelopeReceiverController.cs | 2 +- .../Controllers/HistoryController.cs | 8 +- .../Repositories/EnvelopeHistoryRepository.cs | 6 +- .../Repositories/EnvelopeRepository.cs | 2 +- .../Repositories/EnvlopeReceiverRepository.cs | 2 +- .../HistoryTests.cs | 10 +- .../Controllers/HomeController.cs | 2 +- 38 files changed, 241 insertions(+), 214 deletions(-) diff --git a/EnvelopeGenerator.Application/DocStatus/Commands/ModifyDocStatusCommandBase.cs b/EnvelopeGenerator.Application/DocStatus/Commands/ModifyDocStatusCommandBase.cs index 6833e229..5aa863da 100644 --- a/EnvelopeGenerator.Application/DocStatus/Commands/ModifyDocStatusCommandBase.cs +++ b/EnvelopeGenerator.Application/DocStatus/Commands/ModifyDocStatusCommandBase.cs @@ -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 /// /// Gets the current status code. /// - public Constants.DocumentStatus Status => Value is null ? Constants.DocumentStatus.Created : Constants.DocumentStatus.Signed; + public DocumentStatus Status => Value is null ? DocumentStatus.Created : DocumentStatus.Signed; /// /// Gets or sets the display value associated with the status. diff --git a/EnvelopeGenerator.Application/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs b/EnvelopeGenerator.Application/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs index 7ae0163a..986338ff 100644 --- a/EnvelopeGenerator.Application/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs +++ b/EnvelopeGenerator.Application/Dto/EnvelopeHistory/EnvelopeHistoryDto.cs @@ -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 /// /// Include code of the envelope at this history point. /// - public Constants.EnvelopeStatus Status { get; set; } + public EnvelopeStatus Status { get; set; } /// /// Type of reference for this history entry. /// - 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, }; /// diff --git a/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommand.cs b/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommand.cs index fa988a54..5bd398e7 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommand.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommand.cs @@ -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 /// /// /// Die optionale ID der E-Mail-Vorlage, die zurückgesetzt werden soll. - /// Der Typ der E-Mail-Vorlage, z. B. (optional). - public ResetEmailTemplateCommand(int? Id = null, Constants.EmailTemplateType? Type = null) : base(Id, Type) + /// Der Typ der E-Mail-Vorlage, z. B. (optional). + public ResetEmailTemplateCommand(int? Id = null, EmailTemplateType? Type = null) : base(Id, Type) { } }; \ No newline at end of file diff --git a/EnvelopeGenerator.Application/EmailTemplates/Commands/Update/UpdateEmailTemplateCommandHandler.cs b/EnvelopeGenerator.Application/EmailTemplates/Commands/Update/UpdateEmailTemplateCommandHandler.cs index 6afc0441..09a85eaa 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/Commands/Update/UpdateEmailTemplateCommandHandler.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/Commands/Update/UpdateEmailTemplateCommandHandler.cs @@ -46,7 +46,7 @@ public class UpdateEmailTemplateCommandHandler : IRequestHandler t.Id == id).FirstOrDefaultAsync(cancel); tempDto = _mapper.Map(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(temp); diff --git a/EnvelopeGenerator.Application/EmailTemplates/EmailTemplateQuery.cs b/EnvelopeGenerator.Application/EmailTemplates/EmailTemplateQuery.cs index 7cc3e36e..4c35a1da 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/EmailTemplateQuery.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/EmailTemplateQuery.cs @@ -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". /// /// Die eindeutige Kennung der E-Mail-Vorlage (optional). -/// Der Typ der E-Mail-Vorlage, z. B. (optional). Beispiele: +/// Der Typ der E-Mail-Vorlage, z. B. (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. /// -public record EmailTemplateQuery(int? Id = null, Constants.EmailTemplateType? Type = null) +public record EmailTemplateQuery(int? Id = null, EmailTemplateType? Type = null) { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/EmailTemplates/Queries/Read/ReadEmailTemplateQueryHandler.cs b/EnvelopeGenerator.Application/EmailTemplates/Queries/Read/ReadEmailTemplateQueryHandler.cs index 13acefb3..cfc72e1e 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/Queries/Read/ReadEmailTemplateQueryHandler.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/Queries/Read/ReadEmailTemplateQueryHandler.cs @@ -41,7 +41,7 @@ public class ReadEmailTemplateQueryHandler : IRequestHandler 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); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs b/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs index b9946199..6a896029 100644 --- a/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs +++ b/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs @@ -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 } /// -/// Repräsentiert den Include eines Umschlags und dessen Beziehung zum Empfänger. (vgl. auch +/// Repräsentiert den Include eines Umschlags und dessen Beziehung zum Empfänger. (vgl. auch /// Invalid (0): Ungültiger Include. /// EnvelopeCreated (1001): Der Umschlag wurde erstellt. /// EnvelopeSaved (1002): Der Umschlag wurde gespeichert. @@ -49,20 +48,20 @@ public record EnvelopeStatus /// /// Der minimale Statuswert, der berücksichtigt werden. /// - public Constants.EnvelopeStatus? Min { get; init; } + public Domain.Constants.EnvelopeStatus? Min { get; init; } /// /// Der maximale Statuswert, der berücksichtigt werden. /// - public Constants.EnvelopeStatus? Max { get; init; } + public Domain.Constants.EnvelopeStatus? Max { get; init; } /// /// Eine Liste von Statuswerten, die einbezogen werden. /// - public Constants.EnvelopeStatus[]? Include { get; init; } + public Domain.Constants.EnvelopeStatus[]? Include { get; init; } /// /// Eine Liste von Statuswerten, die ignoriert werden werden. /// - public Constants.EnvelopeStatus[]? Ignore { get; init; } + public Domain.Constants.EnvelopeStatus[]? Ignore { get; init; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Extensions/DecodingExtensions.cs b/EnvelopeGenerator.Application/Extensions/DecodingExtensions.cs index 0f43df21..28767485 100644 --- a/EnvelopeGenerator.Application/Extensions/DecodingExtensions.cs +++ b/EnvelopeGenerator.Application/Extensions/DecodingExtensions.cs @@ -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; + +/// +/// +/// +public static class DecodingExtensions { - public static class DecodingExtensions + /// + /// Validates whether a given string is a correctly formatted Base-64 encoded string. + /// + /// + /// 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). + /// + /// The Base-64 encoded string to validate. + /// + /// true if the string is a valid Base-64 encoded string; otherwise, false. + /// + /// + /// + /// string testString = "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnk="; + /// bool isValid = IsValidBase64String(testString); + /// Console.WriteLine(isValid); // Output: true + /// + /// + public static bool IsBase64String(this string input) { - /// - /// Validates whether a given string is a correctly formatted Base-64 encoded string. - /// - /// - /// 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). - /// - /// The Base-64 encoded string to validate. - /// - /// true if the string is a valid Base-64 encoded string; otherwise, false. - /// - /// - /// - /// string testString = "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnk="; - /// bool isValid = IsValidBase64String(testString); - /// Console.WriteLine(isValid); // Output: true - /// - /// - 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 false; + } - return input.IndexOf('=') == -1; // No padding allowed except at the end + // 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; } - public static bool TryDecode(this string encodedKey, out string[] decodedKeys) + // Check each character to ensure it is valid base-64 + foreach (char c in input) { - try + if (!char.IsLetterOrDigit(c) && c != '+' && c != '/' && c != '=') { - byte[] bytes = Convert.FromBase64String(encodedKey); - string decodedString = Encoding.UTF8.GetString(bytes); - decodedKeys = decodedString.Split(new string[] { "::" }, StringSplitOptions.None); - return true; + // Invalid character detected + return false; } - catch(ArgumentNullException) { } - catch (FormatException) { } - catch(ArgumentException) { } - - decodedKeys = Array.Empty(); - return false; } - public static EncodeType GetEncodeType(this string[] decodedKeys) => decodedKeys.Length switch + // Ensure no invalid padding scenarios exist + if (input.EndsWith("==") && (input.Length % 4 == 0) || + input.EndsWith("=") && (input.Length % 4 == 3)) { - 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. "); - - /// - /// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature. - /// - /// The base64 encoded string containing the envelope UUID and receiver signature. - /// A tuple containing the envelope UUID and receiver signature. - public static (string? EnvelopeUuid, string? ReceiverSignature) DecodeEnvelopeReceiverId(this string envelopeReceiverId) + return true; + } + + return input.IndexOf('=') == -1; // No padding allowed except at the end + } + + /// + /// + /// + /// + /// + /// + public static bool TryDecode(this string encodedKey, out string[] decodedKeys) + { + try { - if (!envelopeReceiverId.IsBase64String()) - { - return (null, null); - } - byte[] bytes = Convert.FromBase64String(envelopeReceiverId); + byte[] bytes = Convert.FromBase64String(encodedKey); 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); + decodedKeys = decodedString.Split(new string[] { "::" }, StringSplitOptions.None); + return true; } + catch(ArgumentNullException) { } + catch (FormatException) { } + catch(ArgumentException) { } + + decodedKeys = Array.Empty(); + return false; + } - public static long? DecodeEnvelopeReceiverReadOnlyId(this string envelopeReceiverReadOnlyId) + /// + /// + /// + /// + /// + 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, + }; + + /// + /// + /// + /// + /// + /// + 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. "); + + /// + /// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature. + /// + /// The base64 encoded string containing the envelope UUID and receiver signature. + /// A tuple containing the envelope UUID and receiver signature. + public static (string? EnvelopeUuid, string? ReceiverSignature) DecodeEnvelopeReceiverId(this string envelopeReceiverId) + { + if (!envelopeReceiverId.IsBase64String()) { - 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; + 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); + } - /// - /// Gets the envelope UUID from the decoded envelope receiver ID. - /// - /// The base64 encoded string to decode. - /// The envelope UUID. - public static string? GetEnvelopeUuid(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().EnvelopeUuid; - - /// - /// Gets the receiver signature from the decoded envelope receiver ID. - /// - /// The base64 encoded string to decode. - /// The receiver signature. - public static string? GetReceiverSignature(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().ReceiverSignature; + /// + /// + /// + /// + /// + 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; } + + /// + /// Gets the envelope UUID from the decoded envelope receiver ID. + /// + /// The base64 encoded string to decode. + /// The envelope UUID. + public static string? GetEnvelopeUuid(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().EnvelopeUuid; + + /// + /// Gets the receiver signature from the decoded envelope receiver ID. + /// + /// The base64 encoded string to decode. + /// The receiver signature. + public static string? GetReceiverSignature(this string envelopeReceiverId) => envelopeReceiverId.DecodeEnvelopeReceiverId().ReceiverSignature; } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs index 27490d43..61bc4bcd 100644 --- a/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs +++ b/EnvelopeGenerator.Application/Histories/Queries/ReadHistoryQuery.cs @@ -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>; \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Interfaces/Repositories/IEmailTemplateRepository.cs b/EnvelopeGenerator.Application/Interfaces/Repositories/IEmailTemplateRepository.cs index b2b2e750..e200690f 100644 --- a/EnvelopeGenerator.Application/Interfaces/Repositories/IEmailTemplateRepository.cs +++ b/EnvelopeGenerator.Application/Interfaces/Repositories/IEmailTemplateRepository.cs @@ -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; diff --git a/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeHistoryRepository.cs b/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeHistoryRepository.cs index 8c744d3e..089d875c 100644 --- a/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeHistoryRepository.cs +++ b/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeHistoryRepository.cs @@ -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 /// /// - Task CountAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null); + Task CountAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null); /// /// @@ -28,5 +28,5 @@ public interface IEnvelopeHistoryRepository : ICRUDRepository /// /// - Task> ReadAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false); + Task> ReadAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeReceiverRepository.cs b/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeReceiverRepository.cs index 6797cdfe..0844e843 100644 --- a/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeReceiverRepository.cs +++ b/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeReceiverRepository.cs @@ -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 /// /// - Task> ReadByUsernameAsync(string username, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses); + Task> ReadByUsernameAsync(string username, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, params EnvelopeStatus[] ignore_statuses); /// /// diff --git a/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeRepository.cs b/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeRepository.cs index 3cada696..deb607a1 100644 --- a/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeRepository.cs +++ b/EnvelopeGenerator.Application/Interfaces/Repositories/IEnvelopeRepository.cs @@ -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 /// /// /// - Task> ReadByUserAsync(int userId, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses); + Task> ReadByUserAsync(int userId, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, params EnvelopeStatus[] ignore_statuses); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Interfaces/Services/IEmailTemplateService.cs b/EnvelopeGenerator.Application/Interfaces/Services/IEmailTemplateService.cs index 546fec3a..d88ce096 100644 --- a/EnvelopeGenerator.Application/Interfaces/Services/IEmailTemplateService.cs +++ b/EnvelopeGenerator.Application/Interfaces/Services/IEmailTemplateService.cs @@ -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; diff --git a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeHistoryService.cs b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeHistoryService.cs index 86d84b38..80dc1fc2 100644 --- a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeHistoryService.cs +++ b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeHistoryService.cs @@ -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; diff --git a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeMailService.cs b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeMailService.cs index c55785d1..a4fd19b3 100644 --- a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeMailService.cs +++ b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeMailService.cs @@ -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 /// /// /// - Task> SendAsync(EnvelopeReceiverDto envelopeReceiverDto, Constants.EmailTemplateType tempType, Dictionary? optionalPlaceholders = null); + Task> SendAsync(EnvelopeReceiverDto envelopeReceiverDto, EmailTemplateType tempType, Dictionary? optionalPlaceholders = null); /// /// diff --git a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeReceiverService.cs b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeReceiverService.cs index 7829668a..82d3862f 100644 --- a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeReceiverService.cs +++ b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeReceiverService.cs @@ -122,7 +122,7 @@ public interface IEnvelopeReceiverService : IBasicCRUDService /// /// - Task>> 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>> ReadByUsernameAsync(string username, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, ReadEnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params EnvelopeStatus[] ignore_statuses); /// /// diff --git a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeService.cs b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeService.cs index ab49de57..f5556c2d 100644 --- a/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeService.cs +++ b/EnvelopeGenerator.Application/Interfaces/Services/IEnvelopeService.cs @@ -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 /// /// - Task>> ReadByUserAsync(int userId, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses); + Task>> ReadByUserAsync(int userId, Domain.Constants.EnvelopeStatus? min_status = null, Domain.Constants.EnvelopeStatus? max_status = null, params Domain.Constants.EnvelopeStatus[] ignore_statuses); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/EmailTemplateService.cs b/EnvelopeGenerator.Application/Services/EmailTemplateService.cs index 97aaa752..5cfa62d6 100644 --- a/EnvelopeGenerator.Application/Services/EmailTemplateService.cs +++ b/EnvelopeGenerator.Application/Services/EmailTemplateService.cs @@ -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; diff --git a/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs b/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs index d7e2847a..801a292a 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs @@ -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; diff --git a/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs b/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs index 54264b9f..2c1bab9b 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs @@ -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> SendAsync(EnvelopeReceiverReadOnlyDto dto, Di { var tempSerResult = await _tempService.ReadByNameAsync(EmailTemplateType.DocumentShared); if (tempSerResult.IsFailed) - return tempSerResult.ToFail().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"The email cannot send because '{Constants.EmailTemplateType.DocumentShared}' template cannot found."); + return tempSerResult.ToFail().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"The email cannot send because '{EmailTemplateType.DocumentShared}' template cannot found."); var temp = tempSerResult.Data; var mail = new EmailOutCreateDto() diff --git a/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs b/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs index b73337cd..0e27b85e 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs @@ -239,7 +239,7 @@ public class EnvelopeReceiverService : BasicCRUDService /// /// - public async Task>> 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>> 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 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) diff --git a/EnvelopeGenerator.Application/Services/EnvelopeService.cs b/EnvelopeGenerator.Application/Services/EnvelopeService.cs index 594486e8..f0740263 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeService.cs @@ -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 /// /// - public async Task>> ReadByUserAsync(int userId, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses) + public async Task>> 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>(users); diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/ReportItem.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/ReportItem.vb index 01b363f7..b337402f 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/ReportItem.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/ReportItem.vb @@ -8,7 +8,7 @@ Public Class ReportItem Public Property EnvelopeTitle As String Public Property EnvelopeSubject As String - Public Property ItemStatus As Constants.EnvelopeStatus + Public Property ItemStatus As EnvelopeStatus Public ReadOnly Property ItemStatusTranslated As String Get Dim oStatus = ItemStatus.ToString() diff --git a/EnvelopeGenerator.CommonServices/Models/EmailData.vb b/EnvelopeGenerator.CommonServices/Models/EmailData.vb index 0c2d80de..d3ac11f0 100644 --- a/EnvelopeGenerator.CommonServices/Models/EmailData.vb +++ b/EnvelopeGenerator.CommonServices/Models/EmailData.vb @@ -5,7 +5,7 @@ Public Class EmailData Public Property EmailAdress As String = "" Public Property EmailSubject As String = "" Public Property EmailBody As String = "" - Public Property EmailType As Constants.EnvelopeStatus = Constants.EnvelopeStatus.Invalid + Public Property EmailType As EnvelopeStatus = EnvelopeStatus.Invalid Public Property ReferenceID As Integer = 0 Public Property ReferenceString As String = "" @@ -29,7 +29,7 @@ Public Class EmailData ''' ''' ''' - Public Sub New(pEnvelope As Entities.Envelope, pReceiver As ReceiverVM, pStatus As Constants.EnvelopeStatus) + Public Sub New(pEnvelope As Entities.Envelope, pReceiver As ReceiverVM, pStatus As EnvelopeStatus) EmailAdress = pReceiver.EmailAddress EmailSubject = String.Empty EmailType = pStatus @@ -65,7 +65,7 @@ Public Class EmailData ''' ''' ''' - Public Sub New(pEnvelope As Entities.Envelope, pStatus As Constants.EnvelopeStatus) + Public Sub New(pEnvelope As Entities.Envelope, pStatus As EnvelopeStatus) EmailAdress = pEnvelope.User.Email EmailSubject = String.Empty EmailType = pStatus diff --git a/EnvelopeGenerator.CommonServices/Models/EnvelopeModel.vb b/EnvelopeGenerator.CommonServices/Models/EnvelopeModel.vb index bf294d1b..cf40565c 100644 --- a/EnvelopeGenerator.CommonServices/Models/EnvelopeModel.vb +++ b/EnvelopeGenerator.CommonServices/Models/EnvelopeModel.vb @@ -148,7 +148,7 @@ Public Class EnvelopeModel Dim oCommand As New SqlCommand(oSql) 'oCommand.Parameters.Add("MESSAGE", SqlDbType.NVarChar).Value = String.Empty 'oCommand.Parameters.Add("UUID", SqlDbType.NVarChar).Value = pEnvelope.Uuid - 'oCommand.Parameters.Add("STATUS", SqlDbType.Int).Value = Constants.EnvelopeStatus.EnvelopeCreated + 'oCommand.Parameters.Add("STATUS", SqlDbType.Int).Value = EnvelopeStatus.EnvelopeCreated 'oCommand.Parameters.Add("USER_ID", SqlDbType.Int).Value = pEnvelope.UserId diff --git a/EnvelopeGenerator.CommonServices/Models/HistoryModel.vb b/EnvelopeGenerator.CommonServices/Models/HistoryModel.vb index 47c0d08c..8649d823 100644 --- a/EnvelopeGenerator.CommonServices/Models/HistoryModel.vb +++ b/EnvelopeGenerator.CommonServices/Models/HistoryModel.vb @@ -28,7 +28,7 @@ Public Class HistoryModel End Function Public Function HasReceiverSigned(pEnvelopeId As Integer, pReceiverId As Integer) As Boolean - Dim oEnvelopeSigned As Integer = Domain.Constants.EnvelopeStatus.DocumentSigned + Dim oEnvelopeSigned As Integer = Domain.EnvelopeStatus.DocumentSigned Dim oSql = $"SELECT COUNT(T.GUID) FROM TBSIG_ENVELOPE_HISTORY T JOIN TBSIG_RECEIVER T2 ON T.USER_REFERENCE = T2.EMAIL_ADDRESS diff --git a/EnvelopeGenerator.CommonServices/Services/EmailService.vb b/EnvelopeGenerator.CommonServices/Services/EmailService.vb index fb80c54b..78ce21b0 100644 --- a/EnvelopeGenerator.CommonServices/Services/EmailService.vb +++ b/EnvelopeGenerator.CommonServices/Services/EmailService.vb @@ -17,7 +17,7 @@ Public Class EmailService Public Function SendEnvelopeDeletedEmail(pEnvelope As Envelope, pReceiver As ReceiverVM, pReason As String) As Boolean Logger.Debug("SendEnvelopeDeletedEmail - Creating email data object...") - Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageDeletionSent) With + Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.EnvelopeStatus.MessageDeletionSent) With { .SignatureLink = "", .ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP @@ -35,7 +35,7 @@ Public Class EmailService Public Function SendDocumentReceivedEmail(pEnvelope As Envelope, pReceiver As ReceiverVM) As Boolean Logger.Debug("Creating email data object.") - Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageInvitationSent) With + Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.EnvelopeStatus.MessageInvitationSent) With { .SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature), .ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP @@ -55,7 +55,7 @@ Public Class EmailService Logger.Debug($"State.DbConfig.SignatureHost: {State.DbConfig.SignatureHost}") Logger.Debug($" pEnvelope.Uuid: {pEnvelope.Uuid}") Logger.Debug($" pReceiver.Signature: {pReceiver.Signature}") - Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageInvitationSent) With + Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.EnvelopeStatus.MessageInvitationSent) With { .SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature), .ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP @@ -69,7 +69,7 @@ Public Class EmailService Logger.Debug($"State.DbConfig.SignatureHost: {State.DbConfig.SignatureHost}") Logger.Debug($" pEnvelope.Uuid: {pEnvelope.Uuid}") Logger.Debug($" pReceiver.Signature: {pReceiver.Signature}") - Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageAccessCodeSent) With + Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.EnvelopeStatus.MessageAccessCodeSent) With { .SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature), .ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP @@ -87,7 +87,7 @@ Public Class EmailService Public Function SendSignedEmail(pEnvelope As Envelope, pReceiver As ReceiverVM) As Boolean Logger.Debug("Creating email data object.") - Dim oEmailData = New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageConfirmationSent) With + Dim oEmailData = New EmailData(pEnvelope, pReceiver, Domain.EnvelopeStatus.MessageConfirmationSent) With { .SignatureLink = "" } @@ -104,7 +104,7 @@ Public Class EmailService Public Function SendDocumentCompletedEmailToReceiver(pEnvelope As Envelope, pReceiver As ReceiverVM) As Boolean ', pAttachment As String Logger.Debug("Creating email data object.") - Dim oEmailData = New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageCompletionSent) With + Dim oEmailData = New EmailData(pEnvelope, pReceiver, Domain.EnvelopeStatus.MessageCompletionSent) With { .SignatureLink = "", .ATT1_RELATED_ID = pEnvelope.Id, @@ -125,7 +125,7 @@ Public Class EmailService Public Function SendDocumentCompletedEmailToCreator(pEnvelope As Envelope) As Boolean ', pAttachment As String Logger.Debug("Creating email data object.") - Dim oEmailData = New EmailData(pEnvelope, Domain.Constants.EnvelopeStatus.MessageCompletionSent) With + Dim oEmailData = New EmailData(pEnvelope, Domain.EnvelopeStatus.MessageCompletionSent) With { .SignatureLink = "", .ATT1_RELATED_ID = pEnvelope.Id, diff --git a/EnvelopeGenerator.Domain/Entities/Envelope.cs b/EnvelopeGenerator.Domain/Entities/Envelope.cs index 77648690..3cea74ce 100644 --- a/EnvelopeGenerator.Domain/Entities/Envelope.cs +++ b/EnvelopeGenerator.Domain/Entities/Envelope.cs @@ -1,6 +1,8 @@ using DigitalData.UserManager.Domain.Entities; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using EnvelopeGenerator.Domain.Constants; + #if NETFRAMEWORK using System; using System.Collections.Generic; @@ -22,7 +24,7 @@ public class Envelope // TODO: * Check the Form App and remove the default value #if NETFRAMEWORK Id = 0; - Status = Constants.EnvelopeStatus.EnvelopeCreated; + Status = EnvelopeStatus.EnvelopeCreated; Uuid = Guid.NewGuid().ToString(); Message = My.Resources.Envelope.Please_read_and_sign_this_document; Title= string.Empty; @@ -50,7 +52,7 @@ public class Envelope [Required] [Column("STATUS")] - public Constants.EnvelopeStatus Status { get; set; } + public EnvelopeStatus Status { get; set; } [Required] [Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")] @@ -153,7 +155,7 @@ public class Envelope public string CURRENT_WORK_APP { get; set; } = "signFLOW GUI"; [NotMapped] - public bool IsAlreadySent => Status > Constants.EnvelopeStatus.EnvelopeSaved; + public bool IsAlreadySent => Status > EnvelopeStatus.EnvelopeSaved; #endif public List Documents { get; set; } diff --git a/EnvelopeGenerator.Domain/Entities/EnvelopeHistory.cs b/EnvelopeGenerator.Domain/Entities/EnvelopeHistory.cs index 611b3e4b..c71a6109 100644 --- a/EnvelopeGenerator.Domain/Entities/EnvelopeHistory.cs +++ b/EnvelopeGenerator.Domain/Entities/EnvelopeHistory.cs @@ -32,7 +32,7 @@ public class EnvelopeHistory : IHasEnvelope, IHasReceiver [Required] [Column("STATUS")] - public Constants.EnvelopeStatus Status { get; set; } + public EnvelopeStatus Status { get; set; } [Required] [Column("ADDED_WHEN", TypeName = "datetime")] diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeReceiverController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeReceiverController.cs index cbe3aa2c..e05a2095 100644 --- a/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeReceiverController.cs +++ b/EnvelopeGenerator.GeneratorAPI/Controllers/EnvelopeReceiverController.cs @@ -104,7 +104,7 @@ public class EnvelopeReceiverController : ControllerBase max_status: envelopeReceiver.Envelope.Status?.Max, envelopeQuery: envelopeReceiver.Envelope, receiverQuery: envelopeReceiver.Receiver, - ignore_statuses: envelopeReceiver.Envelope.Status?.Ignore ?? Array.Empty()) + ignore_statuses: envelopeReceiver.Envelope.Status?.Ignore ?? Array.Empty()) .ThenAsync( Success: Ok, Fail: IActionResult (msg, ntc) => diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs index e45a183d..22f2660e 100644 --- a/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs +++ b/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs @@ -48,10 +48,10 @@ public class HistoryController : ControllerBase /// [HttpGet("related")] [Authorize] - public IActionResult GetReferenceTypes(Constants.ReferenceType? referenceType = null) + public IActionResult GetReferenceTypes(ReferenceType? referenceType = null) { return referenceType is null - ? Ok(_memoryCache.GetEnumAsDictionary("gen.api", Constants.ReferenceType.Unknown)) + ? Ok(_memoryCache.GetEnumAsDictionary("gen.api", ReferenceType.Unknown)) : Ok(referenceType.ToString()); } @@ -91,10 +91,10 @@ public class HistoryController : ControllerBase /// [HttpGet("status")] [Authorize] - public IActionResult GetEnvelopeStatus([FromQuery] Constants.EnvelopeStatus? status = null) + public IActionResult GetEnvelopeStatus([FromQuery] EnvelopeStatus? status = null) { return status is null - ? Ok(_memoryCache.GetEnumAsDictionary("gen.api", Constants.Status.NonHist, Constants.Status.RelatedToFormApp)) + ? Ok(_memoryCache.GetEnumAsDictionary("gen.api", Constants.Status.NonHist, Constants.Status.RelatedToFormApp)) : Ok(status.ToString()); } diff --git a/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeHistoryRepository.cs b/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeHistoryRepository.cs index 19bb0f09..25763c41 100644 --- a/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeHistoryRepository.cs +++ b/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeHistoryRepository.cs @@ -13,7 +13,7 @@ public class EnvelopeHistoryRepository : CRUDRepository By(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false) + private IQueryable By(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false) { var query = _dbSet.AsNoTracking(); @@ -35,12 +35,12 @@ public class EnvelopeHistoryRepository : CRUDRepository CountAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null) => await By( + public async Task CountAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null) => await By( envelopeId: envelopeId, userReference: userReference, status: status).CountAsync(); - public async Task> ReadAsync(int? envelopeId = null, string? userReference = null, Constants.EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false) + public async Task> ReadAsync(int? envelopeId = null, string? userReference = null, EnvelopeStatus? status = null, bool withSender = false, bool withReceiver = false) => await By( envelopeId: envelopeId, userReference: userReference, diff --git a/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeRepository.cs b/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeRepository.cs index 03f7e0ad..2a1282ae 100644 --- a/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeRepository.cs +++ b/EnvelopeGenerator.Infrastructure/Repositories/EnvelopeRepository.cs @@ -48,7 +48,7 @@ public class EnvelopeRepository : CRUDRepository, IE return await query.FirstOrDefaultAsync(); } - public async Task> ReadByUserAsync(int userId, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses) + public async Task> ReadByUserAsync(int userId, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, params EnvelopeStatus[] ignore_statuses) { var query = _dbSet.AsNoTracking().Where(e => e.UserId == userId); diff --git a/EnvelopeGenerator.Infrastructure/Repositories/EnvlopeReceiverRepository.cs b/EnvelopeGenerator.Infrastructure/Repositories/EnvlopeReceiverRepository.cs index 9ff90935..d20489d8 100644 --- a/EnvelopeGenerator.Infrastructure/Repositories/EnvlopeReceiverRepository.cs +++ b/EnvelopeGenerator.Infrastructure/Repositories/EnvlopeReceiverRepository.cs @@ -80,7 +80,7 @@ public class EnvelopeReceiverRepository : CRUDRepository er.AccessCode) .FirstOrDefaultAsync(); - public async Task> ReadByUsernameAsync(string username, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses) + public async Task> ReadByUsernameAsync(string username, EnvelopeStatus? min_status = null, EnvelopeStatus? max_status = null, params EnvelopeStatus[] ignore_statuses) { var query = _dbSet.AsNoTracking().Where(er => er.Envelope!.User!.Username == username); diff --git a/EnvelopeGenerator.Tests.Application/HistoryTests.cs b/EnvelopeGenerator.Tests.Application/HistoryTests.cs index f942973f..929e1f92 100644 --- a/EnvelopeGenerator.Tests.Application/HistoryTests.cs +++ b/EnvelopeGenerator.Tests.Application/HistoryTests.cs @@ -30,7 +30,7 @@ public class HistoryTests { EnvelopeId = 1, UserReference = "UserA", - Status = Constants.EnvelopeStatus.EnvelopeCreated, + Status = EnvelopeStatus.EnvelopeCreated, Comment = "First create" }; @@ -55,26 +55,26 @@ public class HistoryTests { EnvelopeId = 2, UserReference = "UserX", - Status = Constants.EnvelopeStatus.EnvelopeCreated + Status = EnvelopeStatus.EnvelopeCreated }; var createCmd2 = new CreateHistoryCommand { EnvelopeId = 2, UserReference = "UserX", - Status = Constants.EnvelopeStatus.EnvelopePartlySigned + Status = EnvelopeStatus.EnvelopePartlySigned }; await _host.Mediator.Send(createCmd1); await _host.Mediator.Send(createCmd2); // Act - var result = await _host.Mediator.Send(new ReadHistoryQuery(2, Constants.EnvelopeStatus.EnvelopePartlySigned)); + var result = await _host.Mediator.Send(new ReadHistoryQuery(2, EnvelopeStatus.EnvelopePartlySigned)); // Assert Assert.That(result, Has.Exactly(1).Items); Assert.That(result, Has.All.Matches( - r => r.Status == Constants.EnvelopeStatus.EnvelopePartlySigned)); + r => r.Status == EnvelopeStatus.EnvelopePartlySigned)); } [Test] diff --git a/EnvelopeGenerator.Web/Controllers/HomeController.cs b/EnvelopeGenerator.Web/Controllers/HomeController.cs index 313f1379..2244a257 100644 --- a/EnvelopeGenerator.Web/Controllers/HomeController.cs +++ b/EnvelopeGenerator.Web/Controllers/HomeController.cs @@ -231,7 +231,7 @@ public class HomeController : ViewControllerBase //check the access code verification if (er_secret.AccessCode != auth.AccessCode) { - //Constants.EnvelopeStatus.AccessCodeIncorrect + //EnvelopeStatus.AccessCodeIncorrect await _historyService.RecordAsync(er_secret.EnvelopeId, er_secret.Receiver!.EmailAddress, EnvelopeStatus.AccessCodeIncorrect); Response.StatusCode = StatusCodes.Status401Unauthorized; return View("EnvelopeLocked")