diff --git a/EnvelopeGenerator.Application/Configurations/AuthenticatorParams.cs b/EnvelopeGenerator.Application/Configurations/AuthenticatorParams.cs index bfec74f1..d47088eb 100644 --- a/EnvelopeGenerator.Application/Configurations/AuthenticatorParams.cs +++ b/EnvelopeGenerator.Application/Configurations/AuthenticatorParams.cs @@ -1,19 +1,33 @@ -namespace EnvelopeGenerator.Application.Configurations +namespace EnvelopeGenerator.Application.Configurations; + +/// +/// +/// +public class AuthenticatorParams { - public class AuthenticatorParams - { - public string CharPool { get; init; } = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789012345678901234567890123456789"; + /// + /// Default value is 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789012345678901234567890123456789' + /// + public string CharPool { get; init; } = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789012345678901234567890123456789"; - //TODO: Increase the DefaultTotpSecretKeyLength (e.g. to 32) but make sure that the QR code is generated correctly and can be scanned by the authenticator. - public int DefaultTotpSecretKeyLength { get; init; } = 20; + //TODO: Increase the DefaultTotpSecretKeyLength (e.g. to 32) but make sure that the QR code is generated correctly and can be scanned by the authenticator. + /// + /// Default value is 20 + /// + public int DefaultTotpSecretKeyLength { get; init; } = 20; - public string TotpIssuer { get; init; } = "signFlow"; + /// + /// Default value is + /// + public string TotpIssuer { get; init; } = "signFlow"; - /// - /// 0 is user email, 1 is secret key and 2 is issuer. - /// - public string TotpUrlFormat { get; init; } = "otpauth://totp/{0}?secret={1}&issuer={2}"; + /// + /// 0 is user email, 1 is secret key and 2 is issuer. + /// + public string TotpUrlFormat { get; init; } = "otpauth://totp/{0}?secret={1}&issuer={2}"; - public int TotpQRPixelsPerModule { get; init; } = 20; - } + /// + /// Default value is 20. + /// + public int TotpQRPixelsPerModule { get; init; } = 20; } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Configurations/DbTriggerParams.cs b/EnvelopeGenerator.Application/Configurations/DbTriggerParams.cs index 2fd64896..1afac966 100644 --- a/EnvelopeGenerator.Application/Configurations/DbTriggerParams.cs +++ b/EnvelopeGenerator.Application/Configurations/DbTriggerParams.cs @@ -1,5 +1,8 @@ namespace EnvelopeGenerator.Application.Configurations; +/// +/// +/// public class DbTriggerParams : Dictionary> { -} +} \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Configurations/DispatcherParams.cs b/EnvelopeGenerator.Application/Configurations/DispatcherParams.cs index ca152205..7570601c 100644 --- a/EnvelopeGenerator.Application/Configurations/DispatcherParams.cs +++ b/EnvelopeGenerator.Application/Configurations/DispatcherParams.cs @@ -1,12 +1,27 @@ namespace EnvelopeGenerator.Application.Configurations; +/// +/// +/// public class DispatcherParams { + /// + /// Default value is 1 + /// public int SendingProfile { get; init; } = 1; + /// + /// Defalt value is 'DDEnvelopGenerator' + /// public string AddedWho { get; init; } = "DDEnvelopGenerator"; + /// + /// Default value is 202377 + /// public int ReminderTypeId { get; init; } = 202377; + /// + /// Default value is string.Empty + /// public string EmailAttmt1 { get; init; } = string.Empty; } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Configurations/GtxMessagingParams.cs b/EnvelopeGenerator.Application/Configurations/GtxMessagingParams.cs index 60365683..14f3c7af 100644 --- a/EnvelopeGenerator.Application/Configurations/GtxMessagingParams.cs +++ b/EnvelopeGenerator.Application/Configurations/GtxMessagingParams.cs @@ -6,15 +6,32 @@ namespace EnvelopeGenerator.Application.Configurations; /// public class GtxMessagingParams : IHttpClientOptions { + /// + /// + /// public required string Uri { get; init; } + /// + /// + /// public string? Path { get; init; } + /// + /// + /// public Dictionary? Headers { get; init; } + /// + /// + /// public Dictionary? QueryParams { get; init; } - + /// + /// Default value is 'to' + /// public string RecipientQueryParamName { get; init; } = "to"; + /// + /// Default value is 'text' + /// public string MessageQueryParamName { get; init; } = "text"; } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Configurations/MailParams.cs b/EnvelopeGenerator.Application/Configurations/MailParams.cs index f0a14796..41d16e52 100644 --- a/EnvelopeGenerator.Application/Configurations/MailParams.cs +++ b/EnvelopeGenerator.Application/Configurations/MailParams.cs @@ -1,6 +1,12 @@ namespace EnvelopeGenerator.Application.Configurations; +/// +/// +/// public class MailParams { + /// + /// + /// public required Dictionary Placeholders { get; init; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Configurations/TotpSmsParams.cs b/EnvelopeGenerator.Application/Configurations/TotpSmsParams.cs index 8e9c1765..1a381c96 100644 --- a/EnvelopeGenerator.Application/Configurations/TotpSmsParams.cs +++ b/EnvelopeGenerator.Application/Configurations/TotpSmsParams.cs @@ -1,49 +1,81 @@ using OtpNet; using System.Globalization; -namespace EnvelopeGenerator.Application.Configurations +namespace EnvelopeGenerator.Application.Configurations; + +/// +/// +/// +public class TotpSmsParams { - public class TotpSmsParams + /// + /// The unit is second. + /// + public int TotpStep { get; init; } = 90; + + /// + /// Default value is 'Ihr 2FA-Passwort lautet {0}. Gültig bis {1}' + /// + public string Format { get; init; } = "Ihr 2FA-Passwort lautet {0}. Gültig bis {1}"; + + /// + /// + /// + public ExpirationHandler Expiration { get; init; } = new(); + + /// + /// Default value is VerificationWindow.RfcSpecifiedNetworkDelay + /// + public VerificationWindow? TotpVerificationWindow { get; private init; } = VerificationWindow.RfcSpecifiedNetworkDelay; + + private IEnumerable? _tvwParams; + + /// + /// + /// + public IEnumerable? TotpVerificationWindowParams { - /// - /// The unit is second. - /// - public int TotpStep { get; init; } = 90; - - public string Format { get; init; } = "Ihr 2FA-Passwort lautet {0}. Gültig bis {1}"; - - public ExpirationHandler Expiration { get; init; } = new(); - - public VerificationWindow? TotpVerificationWindow { get; private init; } = VerificationWindow.RfcSpecifiedNetworkDelay; - - private IEnumerable? _tvwParams; - - public IEnumerable? TotpVerificationWindowParams + get => _tvwParams; + init { - get => _tvwParams; - init - { - _tvwParams = value; - if(_tvwParams is not null) - TotpVerificationWindow = new(previous: _tvwParams.ElementAtOrDefault(0), future: _tvwParams.ElementAtOrDefault(0)); - } - } - - public class ExpirationHandler - { - public string CacheKeyFormat { get; init; } = "e{0}_r{1}_sms_code_expiration"; - - public string Format { get; init; } = "HH:mm:ss"; - - public string CultureName - { - get => _cultureInfo.Name; - init => _cultureInfo = new(value); - } - - private CultureInfo _cultureInfo = new("de-DE"); - - public CultureInfo CultureInfo => _cultureInfo; + _tvwParams = value; + if(_tvwParams is not null) + TotpVerificationWindow = new(previous: _tvwParams.ElementAtOrDefault(0), future: _tvwParams.ElementAtOrDefault(0)); } } + + /// + /// + /// + public class ExpirationHandler + { + /// + /// Default value is 'e{0}_r{1}_sms_code_expiration' + /// + public string CacheKeyFormat { get; init; } = "e{0}_r{1}_sms_code_expiration"; + + /// + /// Default value is HH:mm:ss + /// + public string Format { get; init; } = "HH:mm:ss"; + + /// + /// Default value is 'de-DE' + /// + public string CultureName + { + get => _cultureInfo.Name; + init => _cultureInfo = new(value); + } + + /// + /// Default value is 'de-DE' + /// + private CultureInfo _cultureInfo = new("de-DE"); + + /// + /// Default value is 'de-DE' + /// + public CultureInfo CultureInfo => _cultureInfo; + } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IConfigRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IConfigRepository.cs index cf364a8b..f2309a98 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IConfigRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IConfigRepository.cs @@ -1,9 +1,17 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IConfigRepository : ICRUDRepository { + /// + /// + /// + /// Task ReadFirstAsync(); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IDocumentReceiverElementRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IDocumentReceiverElementRepository.cs index cdb980ee..607a8c89 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IDocumentReceiverElementRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IDocumentReceiverElementRepository.cs @@ -1,8 +1,11 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; - +/// +/// +/// +[Obsolete("Use IRepository")] public interface IDocumentReceiverElementRepository : ICRUDRepository { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IDocumentStatusRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IDocumentStatusRepository.cs index bf39dbee..d563bbf1 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IDocumentStatusRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IDocumentStatusRepository.cs @@ -1,8 +1,12 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IDocumentStatusRepository : ICRUDRepository { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IEmailTemplateRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IEmailTemplateRepository.cs index bf672418..a36de569 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IEmailTemplateRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IEmailTemplateRepository.cs @@ -1,10 +1,19 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; -using static EnvelopeGenerator.CommonServices.Constants; +using static EnvelopeGenerator.Domain.Constants; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use Read-method returning IReadQuery instead.")] public interface IEmailTemplateRepository : ICRUDRepository { + /// + /// + /// + /// + /// Task ReadByNameAsync(EmailTemplateType type); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeCertificateRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeCertificateRepository.cs index f3396eb3..10d5e42c 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeCertificateRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeCertificateRepository.cs @@ -1,8 +1,12 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use Read-method returning IReadQuery instead.")] public interface IEnvelopeCertificateRepository : ICRUDRepository { } diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeDocumentRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeDocumentRepository.cs index ed818c86..b999b4b5 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeDocumentRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeDocumentRepository.cs @@ -1,8 +1,12 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IEnvelopeDocumentRepository : ICRUDRepository { } diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeHistoryRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeHistoryRepository.cs index 36b59316..f1ed2758 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeHistoryRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeHistoryRepository.cs @@ -1,11 +1,31 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IEnvelopeHistoryRepository : ICRUDRepository { + /// + /// + /// + /// + /// + /// + /// Task CountAsync(int? envelopeId = null, string? userReference = null, int? status = null); + /// + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeReceiverReadOnlyRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeReceiverReadOnlyRepository.cs index 75e2c4cc..e13accff 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeReceiverReadOnlyRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeReceiverReadOnlyRepository.cs @@ -1,8 +1,12 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IEnvelopeReceiverReadOnlyRepository : ICRUDRepository { } diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeReceiverRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeReceiverRepository.cs index 5537ab64..135071de 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeReceiverRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeReceiverRepository.cs @@ -1,25 +1,95 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// public interface IEnvelopeReceiverRepository : ICRUDRepository { + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// + /// + /// Task ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// Task ReadAccessCodeAsync(string uuid, string signature, bool readOnly = true); + /// + /// + /// + /// + /// + /// Task CountAsync(string uuid, string signature); + /// + /// + /// + /// + /// + /// + /// Task ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// Task ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses); + /// + /// + /// + /// + /// + /// + /// Task ReadLastByReceiverAsync(string? email = null, int? id = null, string? signature = null); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeRepository.cs index c6a112e8..504d63f4 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeRepository.cs @@ -1,13 +1,42 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IEnvelopeRepository : ICRUDRepository { + /// + /// + /// + /// + /// + /// + /// Task> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false); + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Task ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false); + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeTypeRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeTypeRepository.cs index 74f02763..c61e861e 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeTypeRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IEnvelopeTypeRepository.cs @@ -1,8 +1,12 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IEnvelopeTypeRepository : ICRUDRepository { -} +} \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IReceiverRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IReceiverRepository.cs index 865a7341..e0e4968c 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IReceiverRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IReceiverRepository.cs @@ -1,9 +1,19 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IReceiverRepository : ICRUDRepository { + /// + /// + /// + /// + /// + /// Task ReadByAsync(string? emailAddress = null, string? signature = null); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Repositories/IUserReceiverRepository.cs b/EnvelopeGenerator.Application/Contracts/Repositories/IUserReceiverRepository.cs index 299317a2..e94fbd9e 100644 --- a/EnvelopeGenerator.Application/Contracts/Repositories/IUserReceiverRepository.cs +++ b/EnvelopeGenerator.Application/Contracts/Repositories/IUserReceiverRepository.cs @@ -1,8 +1,12 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Repositories; +/// +/// +/// +[Obsolete("Use IRepository")] public interface IUserReceiverRepository : ICRUDRepository { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IAuthenticator.cs b/EnvelopeGenerator.Application/Contracts/Services/IAuthenticator.cs index 419c2e6d..54f5398b 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IAuthenticator.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IAuthenticator.cs @@ -2,17 +2,62 @@ namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// public interface IAuthenticator { + /// + /// + /// + /// + /// string GenerateCode(int length); + /// + /// + /// + /// + /// string GenerateTotpSecretKey(int? length = null); + /// + /// + /// + /// + /// + /// + /// + /// + /// byte[] GenerateTotpQrCode(string userEmail, string secretKey, string? issuer = null, string? totpUrlFormat = null, int? pixelsPerModule = null); + /// + /// + /// + /// + /// + /// + /// + /// + /// byte[] GenerateTotpQrCode(string userEmail, int? length = null, string? issuer = null, string? totpUrlFormat = null, int? pixelsPerModule = null); + /// + /// + /// + /// + /// + /// string GenerateTotp(string secretKey, int step = 30); + /// + /// + /// + /// + /// + /// + /// + /// bool VerifyTotp(string totpCode, string secretKey, int step = 30, VerificationWindow? window = null); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IConfigService.cs b/EnvelopeGenerator.Application/Contracts/Services/IConfigService.cs index f9ffdc86..29d94284 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IConfigService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IConfigService.cs @@ -1,16 +1,31 @@ -using DigitalData.Core.Application.Interfaces; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IConfigService : IReadService { + /// + /// + /// + /// Task> ReadFirstAsync(); + /// + /// + /// + /// Task ReadDefaultAsync(); + /// + /// + /// + /// Task ReadDefaultSignatureHost(); - } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IDocumentReceiverElementService.cs b/EnvelopeGenerator.Application/Contracts/Services/IDocumentReceiverElementService.cs index 3f259557..24fa3f1c 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IDocumentReceiverElementService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IDocumentReceiverElementService.cs @@ -1,9 +1,13 @@ -using DigitalData.Core.Application.Interfaces; +using DigitalData.Core.Abstraction.Application; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IDocumentReceiverElementService : IBasicCRUDService { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IDocumentStatusService.cs b/EnvelopeGenerator.Application/Contracts/Services/IDocumentStatusService.cs index 3c3ae845..27cf664e 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IDocumentStatusService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IDocumentStatusService.cs @@ -1,8 +1,12 @@ -using DigitalData.Core.Application.Interfaces; +using DigitalData.Core.Abstraction.Application; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IDocumentStatusService : IBasicCRUDService { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEmailTemplateService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEmailTemplateService.cs index 9d69a061..92d0ea4c 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEmailTemplateService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEmailTemplateService.cs @@ -1,12 +1,21 @@ -using DigitalData.Core.Application.Interfaces; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using static EnvelopeGenerator.Domain.Constants; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEmailTemplateService : IBasicCRUDService { + /// + /// + /// + /// + /// Task> ReadByNameAsync(EmailTemplateType type); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeCertificateService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeCertificateService.cs index d6ce486c..24409a68 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeCertificateService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeCertificateService.cs @@ -1,9 +1,13 @@ -using DigitalData.Core.Application.Interfaces; +using DigitalData.Core.Abstraction.Application; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEnvelopeCertificateService : IBasicCRUDService { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeDocumentService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeDocumentService.cs index 1c3a8c2d..699094e4 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeDocumentService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeDocumentService.cs @@ -1,9 +1,13 @@ -using DigitalData.Core.Application.Interfaces; +using DigitalData.Core.Abstraction.Application; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEnvelopeDocumentService : IBasicCRUDService { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeHistoryService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeHistoryService.cs index de751549..685ea51b 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeHistoryService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeHistoryService.cs @@ -1,27 +1,85 @@ -using DigitalData.Core.Application.Interfaces; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.DTOs.EnvelopeHistory; using EnvelopeGenerator.Application.DTOs.Receiver; using EnvelopeGenerator.Domain.Entities; -using static EnvelopeGenerator.CommonServices.Constants; +using static EnvelopeGenerator.Domain.Constants; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEnvelopeHistoryService : ICRUDService { + /// + /// + /// + /// + /// + /// + /// Task CountAsync(int? envelopeId = null, string? userReference = null, int? status = null); + /// + /// + /// + /// + /// + /// Task AccessCodeAlreadyRequested(int envelopeId, string userReference); + /// + /// + /// + /// + /// + /// Task IsSigned(int envelopeId, string userReference); + /// + /// + /// + /// + /// + /// Task IsRejected(int envelopeId, string? userReference = null); + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false); + /// + /// + /// + /// + /// + /// Task> ReadRejectedAsync(int envelopeId, string? userReference = null); + /// + /// + /// + /// + /// Task> ReadRejectingReceivers(int envelopeId); + /// + /// + /// + /// + /// + /// + /// + /// Task> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeMailService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeMailService.cs index 3544e3f9..c09a57ba 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeMailService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeMailService.cs @@ -1,18 +1,45 @@ -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application.DTO; using DigitalData.EmailProfilerDispatcher.Abstraction.Contracts; using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly; -using EnvelopeGenerator.CommonServices; +using EnvelopeGenerator.Domain; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEnvelopeMailService : IEmailOutService { + /// + /// + /// + /// + /// + /// + /// Task> SendAsync(EnvelopeReceiverDto envelopeReceiverDto, Constants.EmailTemplateType tempType, Dictionary? optionalPlaceholders = null); + /// + /// + /// + /// + /// + /// Task> SendAsync(EnvelopeReceiverReadOnlyDto dto, Dictionary? optionalPlaceholders = null); + /// + /// + /// + /// + /// Task> SendAccessCodeAsync(EnvelopeReceiverDto envelopeReceiverDto); + /// + /// + /// + /// + /// Task> SendTFAQrCodeAsync(EnvelopeReceiverDto envelopeReceiverDto); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeReceiverReadOnlyService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeReceiverReadOnlyService.cs index e715382b..aea9fe08 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeReceiverReadOnlyService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeReceiverReadOnlyService.cs @@ -1,9 +1,13 @@ -using DigitalData.Core.Application.Interfaces; +using DigitalData.Core.Abstraction.Application; using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEnvelopeReceiverReadOnlyService : ICRUDService { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeReceiverService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeReceiverService.cs index bf759987..7a5b3e63 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeReceiverService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeReceiverService.cs @@ -1,6 +1,6 @@ using CommandDotNet; -using DigitalData.Core.Application.Interfaces; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; using EnvelopeGenerator.Application.DTOs.Messaging; using EnvelopeGenerator.Application.Envelopes; @@ -9,34 +9,140 @@ using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEnvelopeReceiverService : IBasicCRUDService { + /// + /// + /// + /// + /// + /// + /// + /// Task>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// Task>> ReadAccessCodeByUuidAsync(string uuid, bool withEnvelope = false, bool withReceiver = true); + /// + /// + /// + /// + /// + /// + /// + /// Task>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadWithSecretByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true); + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadByEnvelopeReceiverIdAsync(string envelopeReceiverId, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true); + /// + /// + /// + /// + /// + /// Task> ReadAccessCodeByIdAsync(int envelopeId, int receiverId); + /// + /// + /// + /// + /// + /// + /// Task> VerifyAccessCodeAsync(string uuid, string signature, string accessCode); + /// + /// + /// + /// + /// + /// [Command("verify-access-code-async-by-id")] Task> VerifyAccessCodeAsync(string envelopeReceiverId, string accessCode); + /// + /// + /// + /// + /// Task> IsExisting(string envelopeReceiverId); + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Task>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, EnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params int[] ignore_statuses); + /// + /// + /// + /// + /// + /// + /// Task> ReadLastUsedReceiverNameByMailAsync(string? mail = null, int? id = null, string? signature = null); + /// + /// + /// + /// + /// + /// Task> SendSmsAsync(string envelopeReceiverId, string message); + + /// + /// + /// + /// + /// Task>> ReadWithSecretByUuidAsync(string uuid); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeService.cs index 0577bd2f..b799e440 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeService.cs @@ -1,15 +1,44 @@ -using DigitalData.Core.Application.Interfaces; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEnvelopeService : IBasicCRUDService { + /// + /// + /// + /// + /// + /// + /// Task>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false); + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Task> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false); + /// + /// + /// + /// + /// + /// + /// + /// Task>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeSmsHandler.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeSmsHandler.cs index c9ca45ba..c589f394 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeSmsHandler.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeSmsHandler.cs @@ -3,6 +3,9 @@ using EnvelopeGenerator.Application.DTOs.Messaging; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// public interface IEnvelopeSmsHandler { /// @@ -13,5 +16,11 @@ public interface IEnvelopeSmsHandler /// Task<(SmsResponse? SmsResponse, DateTime Expiration)> SendTotpAsync(EnvelopeReceiverSecretDto er_secret, CancellationToken cToken = default); + /// + /// + /// + /// + /// + /// bool VerifyTotp(string totpCode, string secretKey); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeTypeService.cs b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeTypeService.cs index 0766418c..e357ada2 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeTypeService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IEnvelopeTypeService.cs @@ -1,9 +1,13 @@ -using DigitalData.Core.Application.Interfaces; +using DigitalData.Core.Abstraction.Application; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IEnvelopeTypeService : IBasicCRUDService { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IReceiverService.cs b/EnvelopeGenerator.Application/Contracts/Services/IReceiverService.cs index b186034f..0f9293db 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IReceiverService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IReceiverService.cs @@ -1,16 +1,38 @@ using DigitalData.Core.Abstractions; -using DigitalData.Core.Application.Interfaces; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.DTOs.Receiver; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IReceiverService : ICRUDService { + /// + /// + /// + /// + /// + /// Task> ReadByAsync(string? emailAddress = null, string? signature = null); + /// + /// + /// + /// + /// + /// Task DeleteByAsync(string? emailAddress = null, string? signature = null); + /// + /// + /// + /// + /// + /// Task UpdateAsync(TUpdateDto updateDto); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Contracts/Services/IUserReceiverService.cs b/EnvelopeGenerator.Application/Contracts/Services/IUserReceiverService.cs index 4ea378a3..dea30c94 100644 --- a/EnvelopeGenerator.Application/Contracts/Services/IUserReceiverService.cs +++ b/EnvelopeGenerator.Application/Contracts/Services/IUserReceiverService.cs @@ -1,9 +1,13 @@ -using DigitalData.Core.Application.Interfaces; +using DigitalData.Core.Abstraction.Application; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; namespace EnvelopeGenerator.Application.Contracts.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public interface IUserReceiverService : IBasicCRUDService { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/ConfigDto.cs b/EnvelopeGenerator.Application/DTOs/ConfigDto.cs index 5952cc48..00ffb8dd 100644 --- a/EnvelopeGenerator.Application/DTOs/ConfigDto.cs +++ b/EnvelopeGenerator.Application/DTOs/ConfigDto.cs @@ -11,7 +11,7 @@ public class ConfigDto /// /// Gets or sets the path to the document. /// - public string DocumentPath { get; set; } + public string? DocumentPath { get; set; } /// /// Gets or sets the sending profile identifier. @@ -21,15 +21,15 @@ public class ConfigDto /// /// Gets or sets the signature host URL or name. /// - public string SignatureHost { get; set; } + public string? SignatureHost { get; set; } /// /// Gets or sets the name of the external program. /// - public string ExternalProgramName { get; set; } + public string? ExternalProgramName { get; set; } /// /// Gets or sets the path where exports will be saved. /// - public string ExportPath { get; set; } + public string? ExportPath { get; set; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeCertificateDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeCertificateDto.cs index 9b8a2570..a1f11ccf 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeCertificateDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeCertificateDto.cs @@ -21,12 +21,12 @@ public class EnvelopeCertificateDto /// /// Gets the UUID of the envelope. /// - public string EnvelopeUuid { get; init; } + public string EnvelopeUuid { get; init; } = string.Empty; /// /// Gets the subject of the envelope. /// - public string EnvelopeSubject { get; init; } + public string EnvelopeSubject { get; init; } = string.Empty; /// /// Gets the ID of the creator of the envelope. @@ -36,12 +36,12 @@ public class EnvelopeCertificateDto /// /// Gets the name of the creator. /// - public string CreatorName { get; init; } + public string CreatorName { get; init; } = string.Empty; /// /// Gets the email address of the creator. /// - public string CreatorEmail { get; init; } + public string CreatorEmail { get; init; } = string.Empty; /// /// Gets the current status of the envelope. diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeDto.cs index 4a9ea070..063fa7a1 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeDto.cs @@ -5,50 +5,116 @@ using Microsoft.AspNetCore.Mvc; namespace EnvelopeGenerator.Application.DTOs; +/// +/// +/// [ApiExplorerSettings(IgnoreApi = true)] public record EnvelopeDto { + /// + /// + /// public int Id { get; set; } - public int UserId { get; set; } + /// + /// + /// + public int UserId { get; set; } - public int Status { get; set; } + /// + /// + /// + public int Status { get; set; } - public string StatusName { get; set; } + /// + /// Default value is string.Empty + /// + public string StatusName { get; set; } = string.Empty; - public string Uuid { get; set; } + /// + /// Default value is string.Empty + /// + public string Uuid { get; set; } = string.Empty; - [TemplatePlaceholder("[MESSAGE]")] - public string Message { get; set; } + /// + /// Default value is string.Empty + /// + [TemplatePlaceholder("[MESSAGE]")] + public string Message { get; set; } = string.Empty; - public DateTime AddedWhen { get; set; } + /// + /// + /// + public DateTime AddedWhen { get; set; } - public DateTime? ChangedWhen { get; set; } + /// + /// + /// + public DateTime? ChangedWhen { get; set; } - [TemplatePlaceholder("[DOCUMENT_TITLE]")] - public string Title { get; set; } + /// + /// Default value is string.Empty + /// + [TemplatePlaceholder("[DOCUMENT_TITLE]")] + public string Title { get; set; } = string.Empty; - public int? ContractType { get; set; } + /// + /// + /// + public int? ContractType { get; set; } - public string Language { get; set; } + /// + /// Default value is 'de-DE' + /// + public string Language { get; set; } = "de-DE"; - public int? EnvelopeTypeId { get; set; } + /// + /// + /// + public int? EnvelopeTypeId { get; set; } - public int? CertificationType { get; set; } + /// + /// + /// + public int? CertificationType { get; set; } - public bool? UseAccessCode { get; set; } + /// + /// + /// + public bool? UseAccessCode { get; set; } + /// + /// + /// public bool TFAEnabled { get; init; } - public UserReadDto? User { get; set; } + /// + /// + /// + public UserReadDto? User { get; set; } - public EnvelopeType? EnvelopeType { get; set; } + /// + /// + /// + public EnvelopeType? EnvelopeType { get; set; } - public string? EnvelopeTypeTitle { get; set; } + /// + /// + /// + public string? EnvelopeTypeTitle { get; set; } - public bool IsAlreadySent { get; set; } + /// + /// + /// + public bool IsAlreadySent { get; set; } + /// + /// + /// public byte[]? DocResult { get; init; } + /// + /// + /// public IEnumerable? Documents { get; set; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeHistory/EnvelopeHistoryDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeHistory/EnvelopeHistoryDto.cs index 2f566ea9..fa218f71 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeHistory/EnvelopeHistoryDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeHistory/EnvelopeHistoryDto.cs @@ -1,14 +1,13 @@ -using DigitalData.Core.Abstractions; -using DigitalData.UserManager.Application.DTOs.User; +using DigitalData.UserManager.Application.DTOs.User; using EnvelopeGenerator.Application.DTOs.Receiver; -using static EnvelopeGenerator.CommonServices.Constants; +using static EnvelopeGenerator.Domain.Constants; namespace EnvelopeGenerator.Application.DTOs.EnvelopeHistory; /// /// Data Transfer Object representing the history of an envelope, including status, sender, receiver, and related metadata. /// -public record EnvelopeHistoryDto : IUnique +public record EnvelopeHistoryDto { /// /// Unique identifier for the envelope history entry. @@ -23,7 +22,7 @@ public record EnvelopeHistoryDto : IUnique /// /// Reference string for the user related to this history entry. /// - public string UserReference { get; set; } + public required string UserReference { get; set; } /// /// Status code of the envelope at this history point. @@ -66,8 +65,5 @@ public record EnvelopeHistoryDto : IUnique public string? Comment { get; set; } /// - public override int GetHashCode() - { - return Id.GetHashCode(); - } -}; + public override int GetHashCode() => Id.GetHashCode(); +}; \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverBasicDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverBasicDto.cs index 5bbf3891..b4238922 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverBasicDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverBasicDto.cs @@ -1,33 +1,67 @@ -using DigitalData.Core.Abstractions; -using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes; +using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes; using Microsoft.AspNetCore.Mvc; -namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver +namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; + +/// +/// +/// +[ApiExplorerSettings(IgnoreApi = true)] +public record EnvelopeReceiverBasicDto { - [ApiExplorerSettings(IgnoreApi = true)] - public record EnvelopeReceiverBasicDto() : IUnique<(int Envelope, int Receiver)> - { - public (int Envelope, int Receiver) Id => (Envelope: EnvelopeId, Receiver: ReceiverId); + /// + /// + /// + public (int Envelope, int Receiver) Id => (Envelope: EnvelopeId, Receiver: ReceiverId); - public int EnvelopeId { get; init; } + /// + /// + /// + public int EnvelopeId { get; init; } - public int ReceiverId { get; init; } + /// + /// + /// + public int ReceiverId { get; init; } - public int Sequence { get; init; } + /// + /// + /// + public int Sequence { get; init; } - [TemplatePlaceholder("[NAME_RECEIVER]")] - public string? Name { get; init; } + /// + /// + /// + [TemplatePlaceholder("[NAME_RECEIVER]")] + public string? Name { get; init; } - public string? JobTitle { get; init; } + /// + /// + /// + public string? JobTitle { get; init; } - public string? CompanyName { get; init; } + /// + /// + /// + public string? CompanyName { get; init; } - public string? PrivateMessage { get; init; } + /// + /// + /// + public string? PrivateMessage { get; init; } - public DateTime AddedWhen { get; init; } + /// + /// + /// + public DateTime AddedWhen { get; init; } - public DateTime? ChangedWhen { get; init; } + /// + /// + /// + public DateTime? ChangedWhen { get; init; } - public bool HasPhoneNumber { get; init; } - } + /// + /// + /// + public bool HasPhoneNumber { get; init; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverDto.cs index 0ab1ac58..92a4419e 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverDto.cs @@ -1,13 +1,22 @@ using EnvelopeGenerator.Application.DTOs.Receiver; using Microsoft.AspNetCore.Mvc; -namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver -{ - [ApiExplorerSettings(IgnoreApi = true)] - public record EnvelopeReceiverDto() : EnvelopeReceiverBasicDto() - { - public EnvelopeDto? Envelope { get; set; } +namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; - public ReceiverReadDto? Receiver { get; set; } - } +/// +/// +/// + +[ApiExplorerSettings(IgnoreApi = true)] +public record EnvelopeReceiverDto() : EnvelopeReceiverBasicDto() +{ + /// + /// + /// + public EnvelopeDto? Envelope { get; set; } + + /// + /// + /// + public ReceiverReadDto? Receiver { get; set; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverSecretDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverSecretDto.cs index df380980..f6284752 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverSecretDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiver/EnvelopeReceiverSecretDto.cs @@ -1,12 +1,20 @@ using Microsoft.AspNetCore.Mvc; -namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver -{ - [ApiExplorerSettings(IgnoreApi = true)] - public record EnvelopeReceiverSecretDto() : EnvelopeReceiverDto() - { - public string? AccessCode { get; init; } +namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; - public string? PhoneNumber { get; init; } - } +/// +/// +/// +[ApiExplorerSettings(IgnoreApi = true)] +public record EnvelopeReceiverSecretDto : EnvelopeReceiverDto +{ + /// + /// + /// + public string? AccessCode { get; init; } + + /// + /// + /// + public string? PhoneNumber { get; init; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyCreateDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyCreateDto.cs index 2cb09b81..23d6beb9 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyCreateDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyCreateDto.cs @@ -2,23 +2,38 @@ using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; -namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly +namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly; + +/// +/// +/// +/// +[ApiExplorerSettings(IgnoreApi = true)] +public record EnvelopeReceiverReadOnlyCreateDto( + DateTime DateValid) { - [ApiExplorerSettings(IgnoreApi = true)] - public record EnvelopeReceiverReadOnlyCreateDto( - DateTime DateValid) - { - [EmailAddress] - [Required] - public required string ReceiverMail { get; init; } + /// + /// + /// + [EmailAddress] + [Required] + public required string ReceiverMail { get; init; } - [JsonIgnore] - public long? EnvelopeId { get; set; } = null; + /// + /// Default value is null + /// + [JsonIgnore] + public long? EnvelopeId { get; set; } = null; - [JsonIgnore] - public string? AddedWho { get; set; } + /// + /// + /// + [JsonIgnore] + public string? AddedWho { get; set; } - [JsonIgnore] - public DateTime AddedWhen { get; } = DateTime.Now; - }; -} \ No newline at end of file + /// + /// Default value is DateTime.Now + /// + [JsonIgnore] + public DateTime AddedWhen { get; } = DateTime.Now; +}; \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyDto.cs index 82c5d890..1d90df00 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyDto.cs @@ -23,7 +23,7 @@ public class EnvelopeReceiverReadOnlyDto /// /// Gets or inits the email address of the receiver. /// - public string ReceiverMail { get; set; } + public required string ReceiverMail { get; set; } /// /// Gets or inits the date until which the receiver is valid. @@ -37,8 +37,9 @@ public class EnvelopeReceiverReadOnlyDto /// /// Gets or inits the user who added the receiver. + /// Default value is 'unknown'. /// - public string AddedWho { get; init; } + public string AddedWho { get; init; } = "Unknown"; /// /// Gets or inits the associated envelope details. diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyUpdateDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyUpdateDto.cs index 67ff873f..1bb6354a 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyUpdateDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeReceiverReadOnly/EnvelopeReceiverReadOnlyUpdateDto.cs @@ -1,5 +1,4 @@ -using DigitalData.Core.Abstractions; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly; @@ -7,7 +6,7 @@ namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly; /// Data Transfer Object for updating a read-only envelope receiver. /// [ApiExplorerSettings(IgnoreApi = true)] -public class EnvelopeReceiverReadOnlyUpdateDto : IUnique +public class EnvelopeReceiverReadOnlyUpdateDto { /// /// Gets or sets the unique identifier of the envelope receiver. @@ -21,8 +20,9 @@ public class EnvelopeReceiverReadOnlyUpdateDto : IUnique /// /// Gets or sets the name of the user who made the change. + /// Default value is unknown. /// - public string ChangedWho { get; set; } + public string ChangedWho { get; set; } = "Unknown"; /// /// Gets or sets the date and time when the change was made. diff --git a/EnvelopeGenerator.Application/DTOs/EnvelopeTypeDto.cs b/EnvelopeGenerator.Application/DTOs/EnvelopeTypeDto.cs index f00dba2a..78f32506 100644 --- a/EnvelopeGenerator.Application/DTOs/EnvelopeTypeDto.cs +++ b/EnvelopeGenerator.Application/DTOs/EnvelopeTypeDto.cs @@ -16,12 +16,12 @@ public class EnvelopeTypeDto /// /// Gets or sets the title of the envelope type. /// - public string Title { get; set; } + public string Title { get; set; } = string.Empty; /// /// Gets or sets the language code used in this envelope type. /// - public string Language { get; set; } + public string Language { get; set; } = "de-DE"; /// /// Gets or sets the number of days after which the envelope expires. diff --git a/EnvelopeGenerator.Application/DTOs/Messaging/GtxMessagingResponse.cs b/EnvelopeGenerator.Application/DTOs/Messaging/GtxMessagingResponse.cs index 33feb685..b7ff0ab3 100644 --- a/EnvelopeGenerator.Application/DTOs/Messaging/GtxMessagingResponse.cs +++ b/EnvelopeGenerator.Application/DTOs/Messaging/GtxMessagingResponse.cs @@ -1,7 +1,9 @@ using Microsoft.AspNetCore.Mvc; -namespace EnvelopeGenerator.Application.DTOs.Messaging -{ - [ApiExplorerSettings(IgnoreApi = true)] - public class GtxMessagingResponse : Dictionary { } -} \ No newline at end of file +namespace EnvelopeGenerator.Application.DTOs.Messaging; + +/// +/// +/// +[ApiExplorerSettings(IgnoreApi = true)] +public class GtxMessagingResponse : Dictionary { } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/Messaging/SmsResponse.cs b/EnvelopeGenerator.Application/DTOs/Messaging/SmsResponse.cs index 3977cc1a..62b37c41 100644 --- a/EnvelopeGenerator.Application/DTOs/Messaging/SmsResponse.cs +++ b/EnvelopeGenerator.Application/DTOs/Messaging/SmsResponse.cs @@ -1,14 +1,25 @@ using Microsoft.AspNetCore.Mvc; -namespace EnvelopeGenerator.Application.DTOs.Messaging +namespace EnvelopeGenerator.Application.DTOs.Messaging; + +/// +/// +/// +[ApiExplorerSettings(IgnoreApi = true)] +public record SmsResponse { - [ApiExplorerSettings(IgnoreApi = true)] - public record SmsResponse - { - public required bool Ok { get; init; } + /// + /// + /// + public required bool Ok { get; init; } - public bool Failed => !Ok; + /// + /// Returns !Ok + /// + public bool Failed => !Ok; - public dynamic? Errors { get; init; } - } + /// + /// + /// + public dynamic? Errors { get; init; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DTOs/Receiver/ReceiverCreateDto.cs b/EnvelopeGenerator.Application/DTOs/Receiver/ReceiverCreateDto.cs index c05865bb..e20d2be2 100644 --- a/EnvelopeGenerator.Application/DTOs/Receiver/ReceiverCreateDto.cs +++ b/EnvelopeGenerator.Application/DTOs/Receiver/ReceiverCreateDto.cs @@ -5,9 +5,15 @@ using System.Text; namespace EnvelopeGenerator.Application.DTOs.Receiver; +/// +/// +/// [ApiExplorerSettings(IgnoreApi = true)] public record ReceiverCreateDto { + /// + /// + /// public ReceiverCreateDto() { _sha256HexOfMail = new(() => @@ -19,14 +25,29 @@ public record ReceiverCreateDto }); } + /// + /// + /// [EmailAddress] public required string EmailAddress { get; init; } + /// + /// + /// public string? TotpSecretkey { get; init; } + /// + /// var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress.ToUpper());
+ /// var hash_arr = SHA256.HashData(bytes_arr); + /// var hexa_str = BitConverter.ToString(hash_arr); + /// return hexa_str.Replace("-", string.Empty); + ///
public string Signature => _sha256HexOfMail.Value; private readonly Lazy _sha256HexOfMail; + /// + /// Default value is DateTime.Now + /// public DateTime AddedWhen { get; } = DateTime.Now; }; \ No newline at end of file diff --git a/EnvelopeGenerator.Application/DependencyInjection.cs b/EnvelopeGenerator.Application/DependencyInjection.cs index 4e3904d1..b3786a8b 100644 --- a/EnvelopeGenerator.Application/DependencyInjection.cs +++ b/EnvelopeGenerator.Application/DependencyInjection.cs @@ -22,6 +22,7 @@ public static class DependencyInjection /// /// /// + [Obsolete("Use MediatR")] public static IServiceCollection AddEnvelopeGeneratorServices(this IServiceCollection services, IConfiguration config) { //Inject CRUD Service and repositoriesad diff --git a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQueryHandler.cs b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQueryHandler.cs index f074d6d2..2dcec29e 100644 --- a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQueryHandler.cs +++ b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentQueryHandler.cs @@ -1,4 +1,4 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Domain.Entities; using MediatR; @@ -34,6 +34,7 @@ public class ReadDocumentQueryHandler : IRequestHandler /// Thrown when neither nor is provided. /// + [Obsolete("Use MediatR")] public async Task Handle(ReadDocumentQuery query, CancellationToken cancellationToken) { if (query.Id is not null) diff --git a/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommand.cs b/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommand.cs index 298cd11c..1bcfda0e 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommand.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommand.cs @@ -1,4 +1,4 @@ -using EnvelopeGenerator.CommonServices; +using EnvelopeGenerator.Domain; using MediatR; namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Reset; @@ -38,4 +38,4 @@ public record ResetEmailTemplateCommand : EmailTemplateQuery, IRequest public ResetEmailTemplateCommand(int? Id = null, Constants.EmailTemplateType? Type = null) : base(Id, Type) { } -}; +}; \ No newline at end of file diff --git a/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommandHandler.cs b/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommandHandler.cs index 8297225c..d8f59193 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommandHandler.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/Commands/Reset/ResetEmailTemplateCommandHandler.cs @@ -1,4 +1,4 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using MediatR; @@ -27,13 +27,14 @@ public class ResetEmailTemplateCommandHandler : IRequestHandler /// /// + [Obsolete("Use Read-method returning IReadQuery instead.")] public async Task Handle(ResetEmailTemplateCommand request, CancellationToken cancel) { var temps = request.Id is not null ? await _repository.ReadAllAsync(t => t.Id == request.Id, cancel) : request.Type is not null ? await _repository.ReadAllAsync(t => t.Name == request.Type.ToString(), cancel) - : await _repository.ReadAllAsync(ct: cancel); + : await _repository.ReadAllAsync(cancellation: cancel); foreach (var temp in temps) { diff --git a/EnvelopeGenerator.Application/EmailTemplates/Commands/Update/UpdateEmailTemplateCommandHandler.cs b/EnvelopeGenerator.Application/EmailTemplates/Commands/Update/UpdateEmailTemplateCommandHandler.cs index 10d4e6f1..deb70651 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/Commands/Update/UpdateEmailTemplateCommandHandler.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/Commands/Update/UpdateEmailTemplateCommandHandler.cs @@ -1,6 +1,7 @@ -using DigitalData.Core.Application.Interfaces.Repository; +using DigitalData.Core.Abstraction.Application.Repository; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Application.Exceptions; +using EnvelopeGenerator.Domain; using EnvelopeGenerator.Domain.Entities; using MediatR; @@ -30,6 +31,7 @@ public class UpdateEmailTemplateCommandHandler : IRequestHandler /// /// + [Obsolete("Use Read-method returning IReadQuery instead.")] public async Task Handle(UpdateEmailTemplateCommand request, CancellationToken cancel) { EmailTemplateDto? temp; @@ -38,7 +40,7 @@ public class UpdateEmailTemplateCommandHandler : IRequestHandler(t => t.Id == id, single: false, cancel); } - else if (request!.EmailTemplateQuery!.Type is Common.Constants.EmailTemplateType type) + else if (request!.EmailTemplateQuery!.Type is Constants.EmailTemplateType type) { temp = await _repository.ReadOrDefaultAsync(t => t.Name == type.ToString(), single: false, cancel); } diff --git a/EnvelopeGenerator.Application/EmailTemplates/EmailTemplateQuery.cs b/EnvelopeGenerator.Application/EmailTemplates/EmailTemplateQuery.cs index 6d0289ae..7cc3e36e 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/EmailTemplateQuery.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/EmailTemplateQuery.cs @@ -1,4 +1,4 @@ -using EnvelopeGenerator.CommonServices; +using EnvelopeGenerator.Domain; namespace EnvelopeGenerator.Application.EmailTemplates; @@ -21,4 +21,4 @@ namespace EnvelopeGenerator.Application.EmailTemplates; /// public record EmailTemplateQuery(int? Id = null, Constants.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 1ab779f5..7967077d 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/Queries/Read/ReadEmailTemplateQueryHandler.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/Queries/Read/ReadEmailTemplateQueryHandler.cs @@ -2,6 +2,7 @@ using EnvelopeGenerator.Application.Contracts.Repositories; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.CommonServices; +using EnvelopeGenerator.Domain; using MediatR; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; diff --git a/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj b/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj index f92b52d7..5ffe315d 100644 --- a/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj +++ b/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj @@ -14,10 +14,10 @@ - - + + - + diff --git a/EnvelopeGenerator.Application/Envelopes/Queries/Read/ReadEnvelopeResponse.cs b/EnvelopeGenerator.Application/Envelopes/Queries/Read/ReadEnvelopeResponse.cs index de6609b3..8e9a9b13 100644 --- a/EnvelopeGenerator.Application/Envelopes/Queries/Read/ReadEnvelopeResponse.cs +++ b/EnvelopeGenerator.Application/Envelopes/Queries/Read/ReadEnvelopeResponse.cs @@ -1,4 +1,5 @@ using EnvelopeGenerator.CommonServices; +using EnvelopeGenerator.Domain; namespace EnvelopeGenerator.Application.Envelopes.Queries.Read; diff --git a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQuery.cs b/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQuery.cs index ddef527d..6d8b4ecf 100644 --- a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQuery.cs +++ b/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryQuery.cs @@ -1,4 +1,4 @@ -using EnvelopeGenerator.CommonServices; +using EnvelopeGenerator.Domain; using MediatR; using System.ComponentModel.DataAnnotations; diff --git a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryResponse.cs b/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryResponse.cs index cb810a05..db05bb2f 100644 --- a/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryResponse.cs +++ b/EnvelopeGenerator.Application/Histories/Queries/Read/ReadHistoryResponse.cs @@ -1,4 +1,5 @@ using EnvelopeGenerator.CommonServices; +using EnvelopeGenerator.Domain; namespace EnvelopeGenerator.Application.Histories.Queries.Read; @@ -30,7 +31,7 @@ public class ReadHistoryResponse /// /// /// - public Common.Constants.ReferenceType ReferenceType => Status.ToString().FirstOrDefault() switch + public Constants.ReferenceType ReferenceType => Status.ToString().FirstOrDefault() switch { '1' => Constants.ReferenceType.Sender, '2' => Constants.ReferenceType.Receiver, diff --git a/EnvelopeGenerator.Application/Key.cs b/EnvelopeGenerator.Application/Key.cs index 52f35d19..53d0a40d 100644 --- a/EnvelopeGenerator.Application/Key.cs +++ b/EnvelopeGenerator.Application/Key.cs @@ -1,20 +1,77 @@ -namespace EnvelopeGenerator.Application +namespace EnvelopeGenerator.Application; + +/// +/// +/// +public static class Key { - public static class Key - { - public static readonly string InnerServiceError = nameof(InnerServiceError); - public static readonly string EnvelopeNotFound = nameof(EnvelopeNotFound); - public static readonly string EnvelopeReceiverNotFound = nameof(EnvelopeReceiverNotFound); - public static readonly string AccessCodeNull = nameof(AccessCodeNull); - public static readonly string WrongAccessCode = nameof(WrongAccessCode); - public static readonly string DataIntegrityIssue = nameof(DataIntegrityIssue); - public static readonly string SecurityBreachOrDataIntegrity = nameof(SecurityBreachOrDataIntegrity); - public static readonly string PossibleDataIntegrityIssue = nameof(PossibleDataIntegrityIssue); - public static readonly string SecurityBreach = nameof(SecurityBreach); - public static readonly string PossibleSecurityBreach = nameof(PossibleSecurityBreach); - public static readonly string WrongEnvelopeReceiverId = nameof(WrongEnvelopeReceiverId); - public static readonly string EnvelopeOrReceiverNonexists = nameof(EnvelopeOrReceiverNonexists); - public static readonly string PhoneNumberNonexists = nameof(PhoneNumberNonexists); - public static readonly string Default = nameof(Default); - } + /// + /// + /// + public static readonly string InnerServiceError = nameof(InnerServiceError); + + /// + /// + /// + public static readonly string EnvelopeNotFound = nameof(EnvelopeNotFound); + + /// + /// + /// + public static readonly string EnvelopeReceiverNotFound = nameof(EnvelopeReceiverNotFound); + + /// + /// + /// + public static readonly string AccessCodeNull = nameof(AccessCodeNull); + + /// + /// + /// + public static readonly string WrongAccessCode = nameof(WrongAccessCode); + + /// + /// + /// + public static readonly string DataIntegrityIssue = nameof(DataIntegrityIssue); + + /// + /// + /// + public static readonly string SecurityBreachOrDataIntegrity = nameof(SecurityBreachOrDataIntegrity); + + /// + /// + /// + public static readonly string PossibleDataIntegrityIssue = nameof(PossibleDataIntegrityIssue); + + /// + /// + /// + public static readonly string SecurityBreach = nameof(SecurityBreach); + + /// + /// + /// + public static readonly string PossibleSecurityBreach = nameof(PossibleSecurityBreach); + + /// + /// + /// + public static readonly string WrongEnvelopeReceiverId = nameof(WrongEnvelopeReceiverId); + + /// + /// + /// + public static readonly string EnvelopeOrReceiverNonexists = nameof(EnvelopeOrReceiverNonexists); + + /// + /// + /// + public static readonly string PhoneNumberNonexists = nameof(PhoneNumberNonexists); + + /// + /// + /// + public static readonly string Default = nameof(Default); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/Authenticator.cs b/EnvelopeGenerator.Application/Services/Authenticator.cs index 84bc7027..ed6e51ee 100644 --- a/EnvelopeGenerator.Application/Services/Authenticator.cs +++ b/EnvelopeGenerator.Application/Services/Authenticator.cs @@ -5,67 +5,123 @@ using OtpNet; using QRCoder; using System.Text; -namespace EnvelopeGenerator.Application.Services +namespace EnvelopeGenerator.Application.Services; + +/// +/// +/// +public class Authenticator : IAuthenticator { - public class Authenticator : IAuthenticator + /// + /// + /// + public static Lazy LazyStatic => new(() => new Authenticator(Options.Create(new()), new QRCodeGenerator())); + + /// + /// + /// + public static Authenticator Static => LazyStatic.Value; + + private readonly AuthenticatorParams _params; + + private readonly QRCodeGenerator _qrCodeGenerator; + + /// + /// + /// + /// + /// + public Authenticator(IOptions options, QRCodeGenerator qrCodeGenerator) { - public static Lazy LazyStatic => new(() => new Authenticator(Options.Create(new()), new QRCodeGenerator())); - - public static Authenticator Static => LazyStatic.Value; - - private readonly AuthenticatorParams _params; - - private readonly QRCodeGenerator _qrCodeGenerator; - - public Authenticator(IOptions options, QRCodeGenerator qrCodeGenerator) - { - _params = options.Value; - _qrCodeGenerator = qrCodeGenerator; - } - - public string GenerateCode(int length) - { - //TODO: Inject Random as a singleton to support multithreading to improve performance. - Random random = new(); - - if (length <= 0) - throw new ArgumentException("Password length must be greater than 0."); - - var passwordBuilder = new StringBuilder(length); - - for (int i = 0; i < length; i++) - passwordBuilder.Append(_params.CharPool[random.Next(_params.CharPool.Length)]); - - return passwordBuilder.ToString(); - } - - public string GenerateTotpSecretKey(int? length = null) - => Base32Encoding.ToString(KeyGeneration.GenerateRandomKey(length ?? _params.DefaultTotpSecretKeyLength)); - - public byte[] GenerateTotpQrCode(string userEmail, string secretKey, string? issuer = null, string? totpUrlFormat = null, int? pixelsPerModule = null) - { - var url = string.Format(totpUrlFormat ?? _params.TotpUrlFormat, - Uri.EscapeDataString(userEmail), - Uri.EscapeDataString(secretKey), - Uri.EscapeDataString(issuer ?? _params.TotpIssuer)); - using var qrCodeData = _qrCodeGenerator.CreateQrCode(url, QRCodeGenerator.ECCLevel.Q); - using var qrCode = new BitmapByteQRCode(qrCodeData); - return qrCode.GetGraphic(pixelsPerModule ?? _params.TotpQRPixelsPerModule); - } - - public byte[] GenerateTotpQrCode(string userEmail, int? length = null, string? issuer = null, string? totpUrlFormat = null, int? pixelsPerModule = null) - { - return GenerateTotpQrCode( - userEmail: userEmail, - secretKey: GenerateTotpSecretKey(length: length), - issuer: issuer, - totpUrlFormat: totpUrlFormat, - pixelsPerModule: pixelsPerModule); - } - - public string GenerateTotp(string secretKey, int step = 30) => new Totp(Base32Encoding.ToBytes(secretKey), step).ComputeTotp(); - - public bool VerifyTotp(string totpCode, string secretKey, int step = 30, VerificationWindow? window = null) - => new Totp(Base32Encoding.ToBytes(secretKey), step).VerifyTotp(totpCode, out _, window); + _params = options.Value; + _qrCodeGenerator = qrCodeGenerator; } + + /// + /// + /// + /// + /// + /// + public string GenerateCode(int length) + { + //TODO: Inject Random as a singleton to support multithreading to improve performance. + Random random = new(); + + if (length <= 0) + throw new ArgumentException("Password length must be greater than 0."); + + var passwordBuilder = new StringBuilder(length); + + for (int i = 0; i < length; i++) + passwordBuilder.Append(_params.CharPool[random.Next(_params.CharPool.Length)]); + + return passwordBuilder.ToString(); + } + + /// + /// + /// + /// + /// + public string GenerateTotpSecretKey(int? length = null) + => Base32Encoding.ToString(KeyGeneration.GenerateRandomKey(length ?? _params.DefaultTotpSecretKeyLength)); + + /// + /// + /// + /// + /// + /// + /// + /// + /// + public byte[] GenerateTotpQrCode(string userEmail, string secretKey, string? issuer = null, string? totpUrlFormat = null, int? pixelsPerModule = null) + { + var url = string.Format(totpUrlFormat ?? _params.TotpUrlFormat, + Uri.EscapeDataString(userEmail), + Uri.EscapeDataString(secretKey), + Uri.EscapeDataString(issuer ?? _params.TotpIssuer)); + using var qrCodeData = _qrCodeGenerator.CreateQrCode(url, QRCodeGenerator.ECCLevel.Q); + using var qrCode = new BitmapByteQRCode(qrCodeData); + return qrCode.GetGraphic(pixelsPerModule ?? _params.TotpQRPixelsPerModule); + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + public byte[] GenerateTotpQrCode(string userEmail, int? length = null, string? issuer = null, string? totpUrlFormat = null, int? pixelsPerModule = null) + { + return GenerateTotpQrCode( + userEmail: userEmail, + secretKey: GenerateTotpSecretKey(length: length), + issuer: issuer, + totpUrlFormat: totpUrlFormat, + pixelsPerModule: pixelsPerModule); + } + + /// + /// + /// + /// + /// + /// + public string GenerateTotp(string secretKey, int step = 30) => new Totp(Base32Encoding.ToBytes(secretKey), step).ComputeTotp(); + + /// + /// + /// + /// + /// + /// + /// + /// + public bool VerifyTotp(string totpCode, string secretKey, int step = 30, VerificationWindow? window = null) + => new Totp(Base32Encoding.ToBytes(secretKey), step).VerifyTotp(totpCode, out _, window); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/ConfigService.cs b/EnvelopeGenerator.Application/Services/ConfigService.cs index 0c98c48b..c7f26acf 100644 --- a/EnvelopeGenerator.Application/Services/ConfigService.cs +++ b/EnvelopeGenerator.Application/Services/ConfigService.cs @@ -1,26 +1,44 @@ using AutoMapper; using DigitalData.Core.Application; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.Contracts.Services; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Contracts.Repositories; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; + namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class ConfigService : ReadService, IConfigService { - private static readonly Guid DefaultConfigCacheId = Guid.NewGuid(); + private static readonly Guid DefaultConfigCacheId = Guid.NewGuid(); + + private readonly IMemoryCache _cache; - private readonly IMemoryCache _cache; private readonly ILogger _logger; - public ConfigService(IConfigRepository repository, IMapper mapper, IMemoryCache memoryCache, ILogger logger) : base(repository, mapper) + + /// + /// + /// + /// + /// + /// + /// + public ConfigService(IConfigRepository repository, IMapper mapper, IMemoryCache memoryCache, ILogger logger) : base(repository, mapper) { - _cache = memoryCache; + _cache = memoryCache; _logger = logger; } + /// + /// + /// + /// public async Task> ReadFirstAsync() { var config = await _repository.ReadFirstAsync(); @@ -29,31 +47,36 @@ public class ConfigService : ReadService(config)); } - /// - /// Reads the default configuration asynchronously. - /// - /// - /// The configuration is cached in memory upon the first retrieval. If the configuration is updated, - /// the application needs to be restarted for the changes to take effect as the memory cache will not be updated automatically. - /// - /// - /// A task that represents the asynchronous read operation. The task result contains the default configuration as a . - /// - /// - /// Thrown when the default configuration cannot be found. - /// - public async Task ReadDefaultAsync() + /// + /// Reads the default configuration asynchronously. + /// + /// + /// The configuration is cached in memory upon the first retrieval. If the configuration is updated, + /// the application needs to be restarted for the changes to take effect as the memory cache will not be updated automatically. + /// + /// + /// A task that represents the asynchronous read operation. The task result contains the default configuration as a . + /// + /// + /// Thrown when the default configuration cannot be found. + /// + public async Task ReadDefaultAsync() { var config = await _cache.GetOrCreateAsync(DefaultConfigCacheId, _ => ReadFirstAsync().ThenAsync( - Success: config => config, - Fail: (mssg, ntc) => - { - _logger.LogNotice(ntc); - throw new InvalidOperationException("Default configuration cannot find."); - })); + Success: config => config, + Fail: (mssg, ntc) => + { + _logger.LogNotice(ntc); + throw new InvalidOperationException("Default configuration cannot find."); + }) + ); return config!; } + /// + /// + /// + /// public async Task ReadDefaultSignatureHost() => (await ReadDefaultAsync()).SignatureHost; } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/DocumentReceiverElementService.cs b/EnvelopeGenerator.Application/Services/DocumentReceiverElementService.cs index e30c0311..95f8499e 100644 --- a/EnvelopeGenerator.Application/Services/DocumentReceiverElementService.cs +++ b/EnvelopeGenerator.Application/Services/DocumentReceiverElementService.cs @@ -7,8 +7,18 @@ using EnvelopeGenerator.Application.Contracts.Repositories; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class DocumentReceiverElementService : BasicCRUDService, IDocumentReceiverElementService { + /// + /// + /// + /// + /// + [Obsolete("Use MediatR")] public DocumentReceiverElementService(IDocumentReceiverElementRepository repository, IMapper mapper) : base(repository, mapper) { diff --git a/EnvelopeGenerator.Application/Services/DocumentStatusService.cs b/EnvelopeGenerator.Application/Services/DocumentStatusService.cs index 1b56eee3..813bde2f 100644 --- a/EnvelopeGenerator.Application/Services/DocumentStatusService.cs +++ b/EnvelopeGenerator.Application/Services/DocumentStatusService.cs @@ -7,10 +7,19 @@ using EnvelopeGenerator.Application.Contracts.Repositories; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class DocumentStatusService : BasicCRUDService, IDocumentStatusService { - public DocumentStatusService(IDocumentStatusRepository repository, IMapper mapper) - : base(repository, mapper) + /// + /// + /// + /// + /// + [Obsolete("Use MediatR")] + public DocumentStatusService(IDocumentStatusRepository repository, IMapper mapper) : base(repository, mapper) { } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/EmailTemplateService.cs b/EnvelopeGenerator.Application/Services/EmailTemplateService.cs index 932b43c7..e48ef748 100644 --- a/EnvelopeGenerator.Application/Services/EmailTemplateService.cs +++ b/EnvelopeGenerator.Application/Services/EmailTemplateService.cs @@ -3,20 +3,34 @@ using DigitalData.Core.Application; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Contracts.Repositories; -using static EnvelopeGenerator.CommonServices.Constants; -using DigitalData.Core.DTO; +using static EnvelopeGenerator.Domain.Constants; +using DigitalData.Core.Abstraction.Application.DTO; using Microsoft.Extensions.Logging; using EnvelopeGenerator.Application.Contracts.Services; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class EmailTemplateService : BasicCRUDService, IEmailTemplateService { + /// + /// + /// + /// + /// public EmailTemplateService(IEmailTemplateRepository repository, IMapper mapper) : base(repository, mapper) { } + /// + /// + /// + /// + /// public async Task> ReadByNameAsync(EmailTemplateType type) { var temp = await _repository.ReadByNameAsync(type); diff --git a/EnvelopeGenerator.Application/Services/EnvelopeCertificateService.cs b/EnvelopeGenerator.Application/Services/EnvelopeCertificateService.cs index 5bea1960..ded2f16c 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeCertificateService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeCertificateService.cs @@ -1,6 +1,5 @@ using AutoMapper; using DigitalData.Core.Application; -using Microsoft.Extensions.Localization; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Contracts.Repositories; @@ -8,8 +7,17 @@ using EnvelopeGenerator.Application.Contracts.Services; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class EnvelopeCertificateService : BasicCRUDService, IEnvelopeCertificateService { + /// + /// + /// + /// + /// public EnvelopeCertificateService(IEnvelopeCertificateRepository repository, IMapper mapper) : base(repository, mapper) { diff --git a/EnvelopeGenerator.Application/Services/EnvelopeDocumentService.cs b/EnvelopeGenerator.Application/Services/EnvelopeDocumentService.cs index b8462c26..c55c7408 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeDocumentService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeDocumentService.cs @@ -7,8 +7,18 @@ using EnvelopeGenerator.Application.Contracts.Repositories; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class EnvelopeDocumentService : BasicCRUDService, IEnvelopeDocumentService { + /// + /// + /// + /// + /// + [Obsolete("Use MediatR")] public EnvelopeDocumentService(IEnvelopeDocumentRepository repository, IMapper mapper) : base(repository, mapper) { } diff --git a/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs b/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs index 7e64289a..317c6887 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeHistoryService.cs @@ -2,34 +2,68 @@ using DigitalData.Core.Application; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Contracts.Repositories; -using static EnvelopeGenerator.CommonServices.Constants; -using DigitalData.Core.DTO; +using static EnvelopeGenerator.Domain.Constants; using EnvelopeGenerator.Application.DTOs.EnvelopeHistory; using EnvelopeGenerator.Application.DTOs.Receiver; using EnvelopeGenerator.Application.Contracts.Services; -using DigitalData.Core.Application.DTO; +using DigitalData.Core.Abstraction.Application.DTO; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class EnvelopeHistoryService : CRUDService, IEnvelopeHistoryService { + /// + /// + /// + /// + /// public EnvelopeHistoryService(IEnvelopeHistoryRepository repository, IMapper mapper) : base(repository, mapper) { } + /// + /// / + /// + /// + /// + /// + /// public async Task CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await _repository.CountAsync(envelopeId: envelopeId, userReference: userReference, status: status); + /// + /// + /// + /// + /// + /// + /// public async Task HasStatus(EnvelopeStatus status, int envelopeId, string userReference) => await _repository.CountAsync( envelopeId: envelopeId, userReference: userReference, status: (int) status) > 0; + /// + /// + /// + /// + /// + /// public async Task AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync( envelopeId: envelopeId, userReference:userReference, status: (int) EnvelopeStatus.AccessCodeRequested) > 0; + /// + /// + /// + /// + /// + /// public async Task IsSigned(int envelopeId, string userReference) => await _repository.CountAsync( envelopeId: envelopeId, userReference: userReference, @@ -50,6 +84,16 @@ public class EnvelopeHistoryService : CRUDService 0; } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// public async Task> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false) { var histDTOs = _mapper.Map>( @@ -62,21 +106,40 @@ public class EnvelopeHistoryService : CRUDService h.ReferenceType == referenceType); } + /// + /// + /// + /// + /// + /// public async Task> ReadRejectedAsync(int envelopeId, string? userReference = null) => await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: (int)EnvelopeStatus.DocumentRejected, withReceiver:true); - //TODO: use IQueryable in repository to incerease the performance - public async Task> ReadRejectingReceivers(int envelopeId) - { - var envelopes = await ReadRejectedAsync(envelopeId); - return envelopes is null - ? Enumerable.Empty() - : envelopes - .Where(eh => eh?.Receiver != null) - .Select(eh => eh.Receiver!); - } + //TODO: use IQueryable in repository to incerease the performance + /// + /// + /// + /// + /// + public async Task> ReadRejectingReceivers(int envelopeId) + { + var envelopes = await ReadRejectedAsync(envelopeId); + return envelopes is null + ? Enumerable.Empty() + : envelopes + .Where(eh => eh?.Receiver != null) + .Select(eh => eh.Receiver!); + } - public async Task> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null) => + /// + /// + /// + /// + /// + /// + /// + /// + public async Task> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null) => await CreateAsync(new () { EnvelopeId = envelopeId, @@ -85,8 +148,8 @@ public class EnvelopeHistoryService : CRUDService Result.Success(dto.Id), - Fail: (mssg, ntc) => Result.Fail().Message(mssg).Notice(ntc) - ); + .ThenAsync( + Success: dto => Result.Success(dto.Id), + Fail: (mssg, ntc) => Result.Fail().Message(mssg).Notice(ntc) + ); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs b/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs index 903ef094..076fd11e 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeMailService.cs @@ -1,175 +1,213 @@ using AutoMapper; -using DigitalData.Core.DTO; using DigitalData.EmailProfilerDispatcher.Abstraction.Contracts; using DigitalData.EmailProfilerDispatcher.Abstraction.DTOs.EmailOut; using DigitalData.EmailProfilerDispatcher.Abstraction.Services; using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; -using EnvelopeGenerator.CommonServices; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using static EnvelopeGenerator.CommonServices.Constants; +using static EnvelopeGenerator.Domain.Constants; using EnvelopeGenerator.Extensions; using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly; using EnvelopeGenerator.Application.Configurations; using EnvelopeGenerator.Application.Extensions; using Newtonsoft.Json; using EnvelopeGenerator.Application.Contracts.Services; +using DigitalData.Core.Abstraction.Application.DTO; +using EnvelopeGenerator.Domain; -namespace EnvelopeGenerator.Application.Services +namespace EnvelopeGenerator.Application.Services; + +/// +/// +/// +[Obsolete("Use MediatR")] +public class EnvelopeMailService : EmailOutService, IEnvelopeMailService { - public class EnvelopeMailService : EmailOutService, IEnvelopeMailService +private readonly IEmailTemplateService _tempService; +private readonly IEnvelopeReceiverService _envRcvService; +private readonly DispatcherParams _dConfig; +private readonly IConfigService _configService; +private readonly Dictionary _placeholders; +private readonly IAuthenticator _authenticator; + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// + public EnvelopeMailService(IEmailOutRepository repository, IMapper mapper, IEmailTemplateService tempService, IEnvelopeReceiverService envelopeReceiverService, IOptions dispatcherConfigOptions, IConfigService configService, IOptions mailConfig, IAuthenticator authenticator) : base(repository, mapper) { - private readonly IEmailTemplateService _tempService; - private readonly IEnvelopeReceiverService _envRcvService; - private readonly DispatcherParams _dConfig; - private readonly IConfigService _configService; - private readonly Dictionary _placeholders; - private readonly IAuthenticator _authenticator; + _tempService = tempService; + _envRcvService = envelopeReceiverService; + _dConfig = dispatcherConfigOptions.Value; + _configService = configService; + _placeholders = mailConfig.Value.Placeholders; + _authenticator = authenticator; + } - public EnvelopeMailService(IEmailOutRepository repository, IMapper mapper, IEmailTemplateService tempService, IEnvelopeReceiverService envelopeReceiverService, IOptions dispatcherConfigOptions, IConfigService configService, IOptions mailConfig, IAuthenticator authenticator) : base(repository, mapper) +private async Task> CreatePlaceholders(string? accessCode = null, EnvelopeReceiverDto? envelopeReceiverDto = null) +{ + if (accessCode is not null) + _placeholders["[DOCUMENT_ACCESS_CODE]"] = accessCode; + + if(envelopeReceiverDto?.Envelope is not null && envelopeReceiverDto.Receiver is not null) + { + var erId = (envelopeReceiverDto.Envelope.Uuid, envelopeReceiverDto.Receiver.Signature).EncodeEnvelopeReceiverId(); + var sigHost = await _configService.ReadDefaultSignatureHost(); + var linkToDoc = $"{sigHost}/EnvelopeKey/{erId}"; + _placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc; + _placeholders["[LINK_TO_DOCUMENT_TEXT]"] = linkToDoc[..Math.Min(40, linkToDoc.Length)] + ".."; + } + + return _placeholders; +} + + private async Task> CreatePlaceholders(EnvelopeReceiverReadOnlyDto? readOnlyDto = null) + { + if (readOnlyDto?.Envelope is not null && readOnlyDto.Receiver is not null) { - _tempService = tempService; - _envRcvService = envelopeReceiverService; - _dConfig = dispatcherConfigOptions.Value; - _configService = configService; - _placeholders = mailConfig.Value.Placeholders; - _authenticator = authenticator; + _placeholders["[NAME_RECEIVER]"] = await _envRcvService.ReadLastUsedReceiverNameByMailAsync(readOnlyDto.AddedWho).ThenAsync(res => res, (msg, ntc) => string.Empty) ?? string.Empty; + var erReadOnlyId = (readOnlyDto.Id).EncodeEnvelopeReceiverId(); + var sigHost = await _configService.ReadDefaultSignatureHost(); + var linkToDoc = $"{sigHost}/EnvelopeKey/{erReadOnlyId}"; + _placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc; + _placeholders["[LINK_TO_DOCUMENT_TEXT]"] = linkToDoc[..Math.Min(40, linkToDoc.Length)] + ".."; } - private async Task> CreatePlaceholders(string? accessCode = null, EnvelopeReceiverDto? envelopeReceiverDto = null) - { - if (accessCode is not null) - _placeholders["[DOCUMENT_ACCESS_CODE]"] = accessCode; + return _placeholders; + } + +/// +/// +/// +/// +/// +/// +/// + public async Task> SendAsync(EnvelopeReceiverDto dto, EmailTemplateType tempType, Dictionary? optionalPlaceholders = null) + { + var tempSerResult = await _tempService.ReadByNameAsync(tempType); + if (tempSerResult.IsFailed) + return tempSerResult.ToFail().Notice(LogLevel.Error, DigitalData.Core.Abstraction.Application.DTO.Flag.DataIntegrityIssue, $"The email cannot send because '{tempType}' template cannot found."); + var temp = tempSerResult.Data; - if(envelopeReceiverDto?.Envelope is not null && envelopeReceiverDto.Receiver is not null) - { - var erId = (envelopeReceiverDto.Envelope.Uuid, envelopeReceiverDto.Receiver.Signature).EncodeEnvelopeReceiverId(); - var sigHost = await _configService.ReadDefaultSignatureHost(); - var linkToDoc = $"{sigHost}/EnvelopeKey/{erId}"; - _placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc; - _placeholders["[LINK_TO_DOCUMENT_TEXT]"] = linkToDoc[..Math.Min(40, linkToDoc.Length)] + ".."; - } + var mail = new EmailOutCreateDto() + { + EmailAddress = dto.Receiver!.EmailAddress, + EmailSubj = temp.Subject, + EmailBody = temp.Body, + //email_type = envelope_status, + //message = envelope_message, + ReferenceId = dto.EnvelopeId, //REFERENCE_ID = ENVELOPE_ID + ReferenceString = dto!.Envelope!.Uuid, //REFERENCE_STRING = ENVELOPE_UUID + //receiver_name = receiver.name, + //receiver_access_code = receiver.access_code, + //sender_adress = envelope.user.email, + //sender_name = envelope.user.full_name, + //envelope_title = envelope.title, + ReminderTypeId = _dConfig.ReminderTypeId, + SendingProfile = _dConfig.SendingProfile, + EntityId = null, + WfId = (int) EnvelopeStatus.MessageAccessCodeSent, + WfReference = null, + AddedWho = _dConfig.AddedWho, + EmailAttmt1 = _dConfig.EmailAttmt1 + }; - return _placeholders; - } - - private async Task> CreatePlaceholders(EnvelopeReceiverReadOnlyDto? readOnlyDto = null) - { - if (readOnlyDto?.Envelope is not null && readOnlyDto.Receiver is not null) - { - _placeholders["[NAME_RECEIVER]"] = await _envRcvService.ReadLastUsedReceiverNameByMailAsync(readOnlyDto.AddedWho).ThenAsync(res => res, (msg, ntc) => string.Empty) ?? string.Empty; - var erReadOnlyId = (readOnlyDto.Id).EncodeEnvelopeReceiverId(); - var sigHost = await _configService.ReadDefaultSignatureHost(); - var linkToDoc = $"{sigHost}/EnvelopeKey/{erReadOnlyId}"; - _placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc; - _placeholders["[LINK_TO_DOCUMENT_TEXT]"] = linkToDoc[..Math.Min(40, linkToDoc.Length)] + ".."; - } - - return _placeholders; - } + //get acccess code + var acResult = await _envRcvService.ReadAccessCodeByIdAsync(envelopeId: dto.EnvelopeId, receiverId: dto.ReceiverId); + if (acResult.IsFailed) + return acResult.ToFail().Notice(LogLevel.Error, "Therefore, access code cannot be sent"); + var accessCode = acResult.Data; - public async Task> SendAsync(EnvelopeReceiverDto dto, EmailTemplateType tempType, Dictionary? optionalPlaceholders = null) + var placeholders = await CreatePlaceholders(accessCode: accessCode, envelopeReceiverDto: dto); + + // Add optional place holders. + if (optionalPlaceholders is not null) + foreach (var oph in optionalPlaceholders) + placeholders[oph.Key] = oph.Value.ToString() ?? "NULL"; + + //TODO: remove the requirement to add the models using reflections + return await CreateWithTemplateAsync(createDto: mail,placeholders: placeholders, + dto, dto.Envelope.User!, dto.Envelope); +} + +/// +/// +/// +/// +/// +/// +public async Task> SendAsync(EnvelopeReceiverReadOnlyDto dto, Dictionary? optionalPlaceholders = null) +{ + 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."); + var temp = tempSerResult.Data; + + var mail = new EmailOutCreateDto() { - var tempSerResult = await _tempService.ReadByNameAsync(tempType); - if (tempSerResult.IsFailed) - return tempSerResult.ToFail().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"The email cannot send because '{tempType}' template cannot found."); - var temp = tempSerResult.Data; + EmailAddress = dto.ReceiverMail, + EmailSubj = temp.Subject, + EmailBody = temp.Body, + //TODO: remove int casting when all + ReferenceId = (int) dto.EnvelopeId, //REFERENCE_ID = ENVELOPE_ID + ReferenceString = dto.Envelope!.Uuid, //REFERENCE_STRING = ENVELOPE_UUID + //receiver_name = receiver.name, + //receiver_access_code = receiver.access_code, + //sender_adress = envelope.user.email, + //sender_name = envelope.user.full_name, + //envelope_title = envelope.title, + ReminderTypeId = _dConfig.ReminderTypeId, + SendingProfile = _dConfig.SendingProfile, + EntityId = null, + WfId = (int)EnvelopeStatus.EnvelopeShared, + WfReference = null, + AddedWho = _dConfig.AddedWho, + EmailAttmt1 = _dConfig.EmailAttmt1 + }; - var mail = new EmailOutCreateDto() - { - EmailAddress = dto.Receiver!.EmailAddress, - EmailSubj = temp.Subject, - EmailBody = temp.Body, - //email_type = envelope_status, - //message = envelope_message, - ReferenceId = dto.EnvelopeId, //REFERENCE_ID = ENVELOPE_ID - ReferenceString = dto!.Envelope!.Uuid, //REFERENCE_STRING = ENVELOPE_UUID - //receiver_name = receiver.name, - //receiver_access_code = receiver.access_code, - //sender_adress = envelope.user.email, - //sender_name = envelope.user.full_name, - //envelope_title = envelope.title, - ReminderTypeId = _dConfig.ReminderTypeId, - SendingProfile = _dConfig.SendingProfile, - EntityId = null, - WfId = (int) EnvelopeStatus.MessageAccessCodeSent, - WfReference = null, - AddedWho = _dConfig.AddedWho, - EmailAttmt1 = _dConfig.EmailAttmt1 - }; + var placeholders = await CreatePlaceholders(readOnlyDto: dto); - //get acccess code - var acResult = await _envRcvService.ReadAccessCodeByIdAsync(envelopeId: dto.EnvelopeId, receiverId: dto.ReceiverId); - if (acResult.IsFailed) - return acResult.ToFail().Notice(LogLevel.Error, "Therefore, access code cannot be sent"); - var accessCode = acResult.Data; - - var placeholders = await CreatePlaceholders(accessCode: accessCode, envelopeReceiverDto: dto); + // Add optional place holders. + if (optionalPlaceholders is not null) + foreach (var oph in optionalPlaceholders) + placeholders[oph.Key] = oph.Value.ToString() ?? "NULL"; - // Add optional place holders. - if (optionalPlaceholders is not null) - foreach (var oph in optionalPlaceholders) - placeholders[oph.Key] = oph.Value.ToString() ?? "NULL"; + return await CreateWithTemplateAsync(createDto: mail, placeholders: placeholders, dto.Envelope); + } - //TODO: remove the requirement to add the models using reflections - return await CreateWithTemplateAsync(createDto: mail,placeholders: placeholders, - dto, dto.Envelope.User!, dto.Envelope); - } +/// +/// +/// +/// +/// + public async Task> SendAccessCodeAsync(EnvelopeReceiverDto dto) => await SendAsync(dto: dto, tempType: EmailTemplateType.DocumentAccessCodeReceived); - public async Task> SendAsync(EnvelopeReceiverReadOnlyDto dto, Dictionary? optionalPlaceholders = null) - { - 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."); - var temp = tempSerResult.Data; +/// +/// +/// +/// +/// +/// + public Task> SendTFAQrCodeAsync(EnvelopeReceiverDto dto) + { + // Check if receiver or secret key is null + if (dto.Receiver is null) + throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver information is missing. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}"); + if (dto.Receiver.TotpSecretkey is null) + throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver.TotpSecretKey is null. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}"); - var mail = new EmailOutCreateDto() - { - EmailAddress = dto.ReceiverMail, - EmailSubj = temp.Subject, - EmailBody = temp.Body, - //TODO: remove int casting when all - ReferenceId = (int) dto.EnvelopeId, //REFERENCE_ID = ENVELOPE_ID - ReferenceString = dto.Envelope!.Uuid, //REFERENCE_STRING = ENVELOPE_UUID - //receiver_name = receiver.name, - //receiver_access_code = receiver.access_code, - //sender_adress = envelope.user.email, - //sender_name = envelope.user.full_name, - //envelope_title = envelope.title, - ReminderTypeId = _dConfig.ReminderTypeId, - SendingProfile = _dConfig.SendingProfile, - EntityId = null, - WfId = (int)EnvelopeStatus.EnvelopeShared, - WfReference = null, - AddedWho = _dConfig.AddedWho, - EmailAttmt1 = _dConfig.EmailAttmt1 - }; - - var placeholders = await CreatePlaceholders(readOnlyDto: dto); - - // Add optional place holders. - if (optionalPlaceholders is not null) - foreach (var oph in optionalPlaceholders) - placeholders[oph.Key] = oph.Value.ToString() ?? "NULL"; - - return await CreateWithTemplateAsync(createDto: mail, placeholders: placeholders, dto.Envelope); - } - - public async Task> SendAccessCodeAsync(EnvelopeReceiverDto dto) => await SendAsync(dto: dto, tempType: EmailTemplateType.DocumentAccessCodeReceived); - - public Task> SendTFAQrCodeAsync(EnvelopeReceiverDto dto) - { - // Check if receiver or secret key is null - if (dto.Receiver is null) - throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver information is missing. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}"); - if (dto.Receiver.TotpSecretkey is null) - throw new ArgumentNullException(nameof(dto), $"TFA Qr Code cannot sent. Receiver.TotpSecretKey is null. Envelope receiver dto is {JsonConvert.SerializeObject(dto)}"); - - var totp_qr_64 = _authenticator.GenerateTotpQrCode(userEmail: dto.Receiver.EmailAddress, secretKey: dto.Receiver.TotpSecretkey).ToBase64String(); - return SendAsync(dto, EmailTemplateType.TotpSecret, new() - { - {"[TFA_QR_CODE]", totp_qr_64 }, - }); - } + var totp_qr_64 = _authenticator.GenerateTotpQrCode(userEmail: dto.Receiver.EmailAddress, secretKey: dto.Receiver.TotpSecretkey).ToBase64String(); + return SendAsync(dto, EmailTemplateType.TotpSecret, new() + { + {"[TFA_QR_CODE]", totp_qr_64 }, + }); } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/EnvelopeReceiverReadOnlyService.cs b/EnvelopeGenerator.Application/Services/EnvelopeReceiverReadOnlyService.cs index 74746ee5..c3d39871 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeReceiverReadOnlyService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeReceiverReadOnlyService.cs @@ -7,8 +7,17 @@ using EnvelopeGenerator.Application.Contracts.Repositories; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class EnvelopeReceiverReadOnlyService : CRUDService, IEnvelopeReceiverReadOnlyService { + /// + /// + /// + /// + /// public EnvelopeReceiverReadOnlyService(IEnvelopeReceiverReadOnlyRepository repository, IMapper mapper) : base(repository, mapper) { } diff --git a/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs b/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs index 54e7e79a..fcdec90e 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeReceiverService.cs @@ -1,6 +1,6 @@ using AutoMapper; using DigitalData.Core.Application; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver; using EnvelopeGenerator.Application.Resources; using EnvelopeGenerator.Domain.Entities; diff --git a/EnvelopeGenerator.Application/Services/EnvelopeService.cs b/EnvelopeGenerator.Application/Services/EnvelopeService.cs index 7a0552b9..a7593fc6 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeService.cs @@ -1,6 +1,6 @@ using AutoMapper; using DigitalData.Core.Application; -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.Contracts.Services; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; @@ -8,13 +8,29 @@ using EnvelopeGenerator.Application.Contracts.Repositories; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class EnvelopeService : BasicCRUDService, IEnvelopeService { + /// + /// + /// + /// + /// public EnvelopeService(IEnvelopeRepository repository, IMapper mapper) : base(repository, mapper) { } + /// + /// + /// + /// + /// + /// + /// public async Task>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false) { var envelopes = await _repository.ReadAllWithAsync(documents: documents, history: history, documentReceiverElement: documentReceiverElement); @@ -22,6 +38,16 @@ public class EnvelopeService : BasicCRUDService + /// + ///
+ /// + /// + /// + /// + /// + /// + /// public async Task> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false) { var envelope = await _repository.ReadByUuidAsync(uuid: uuid, withDocuments: withDocuments, withHistory: withHistory, withDocumentReceiverElement: withDocumentReceiverElement, withUser:withUser, withAll:withAll); @@ -33,6 +59,14 @@ public class EnvelopeService : BasicCRUDService + /// + ///
+ /// + /// + /// + /// + /// public async Task>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses) { var users = await _repository.ReadByUserAsync(userId: userId, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses); diff --git a/EnvelopeGenerator.Application/Services/EnvelopeSmsHandler.cs b/EnvelopeGenerator.Application/Services/EnvelopeSmsHandler.cs index e65fcfc8..0ea3b0f5 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeSmsHandler.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeSmsHandler.cs @@ -8,6 +8,9 @@ using Microsoft.Extensions.Options; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// public class EnvelopeSmsHandler : IEnvelopeSmsHandler { private readonly ISmsSender _sender; @@ -18,6 +21,13 @@ public class EnvelopeSmsHandler : IEnvelopeSmsHandler private readonly IAuthenticator _authenticator; + /// + /// + /// + /// + /// + /// + /// public EnvelopeSmsHandler(ISmsSender sender, IOptions totpSmsParamsOptions, IDistributedCache distributedCache, IAuthenticator authenticator) { _sender = sender; @@ -49,6 +59,12 @@ public class EnvelopeSmsHandler : IEnvelopeSmsHandler } } + /// + /// + /// + /// + /// + /// public bool VerifyTotp(string totpCode, string secretKey) => _authenticator .VerifyTotp(totpCode, secretKey, _totpSmsParams.TotpStep, _totpSmsParams.TotpVerificationWindow); } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/EnvelopeTypeService.cs b/EnvelopeGenerator.Application/Services/EnvelopeTypeService.cs index 082ae40b..8c0eba0a 100644 --- a/EnvelopeGenerator.Application/Services/EnvelopeTypeService.cs +++ b/EnvelopeGenerator.Application/Services/EnvelopeTypeService.cs @@ -4,24 +4,38 @@ using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Contracts.Repositories; using Microsoft.Extensions.Caching.Memory; -using DigitalData.Core.DTO; using Microsoft.Extensions.Logging; using EnvelopeGenerator.Application.Contracts.Services; +using DigitalData.Core.Abstraction.Application.DTO; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class EnvelopeTypeService : BasicCRUDService, IEnvelopeTypeService { private static readonly Guid CacheKey = Guid.NewGuid(); private readonly IMemoryCache _cache; + /// + /// + /// + /// + /// + /// public EnvelopeTypeService(IEnvelopeTypeRepository repository, IMapper mapper, IMemoryCache cache) : base(repository, mapper) { _cache = cache; } + /// + /// + /// + /// public override async Task>> ReadAllAsync() => await _cache.GetOrCreateAsync(CacheKey, async entry => await base.ReadAllAsync()) ?? Result.Fail>().Notice(LogLevel.Error, Flag.NotFound, "No cached envelope types are available in the database. If you have added any envelope types after the server started, please restart the server."); diff --git a/EnvelopeGenerator.Application/Services/GTXSmsSender.cs b/EnvelopeGenerator.Application/Services/GTXSmsSender.cs index 9ad767c1..5a5cc26f 100644 --- a/EnvelopeGenerator.Application/Services/GTXSmsSender.cs +++ b/EnvelopeGenerator.Application/Services/GTXSmsSender.cs @@ -9,6 +9,9 @@ using Microsoft.Extensions.Options; namespace EnvelopeGenerator.Application.Services; //TODO: move to DigitalData.Core +/// +/// +/// public class GTXSmsSender : ISmsSender { private readonly IHttpClientService _smsClient; @@ -17,8 +20,17 @@ public class GTXSmsSender : ISmsSender private readonly IMapper _mapper; + /// + /// + /// public string ServiceProvider { get; } + /// + /// + /// + /// + /// + /// public GTXSmsSender(IHttpClientService smsClient, IOptions smsParamsOptions, IMapper mapper) { _smsClient = smsClient; @@ -27,6 +39,12 @@ public class GTXSmsSender : ISmsSender ServiceProvider = GetType().Name.Replace("Service", string.Empty); } + /// + /// + /// + /// + /// + /// public async Task SendSmsAsync(string recipient, string message) { return await _smsClient.FetchAsync(queryParams: new Dictionary() diff --git a/EnvelopeGenerator.Application/Services/ReceiverService.cs b/EnvelopeGenerator.Application/Services/ReceiverService.cs index 72f12bfe..8a7e92ca 100644 --- a/EnvelopeGenerator.Application/Services/ReceiverService.cs +++ b/EnvelopeGenerator.Application/Services/ReceiverService.cs @@ -3,19 +3,33 @@ using DigitalData.Core.Application; using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Contracts.Repositories; using EnvelopeGenerator.Application.DTOs.Receiver; -using DigitalData.Core.DTO; -using Microsoft.Extensions.Logging; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.Contracts.Services; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class ReceiverService : CRUDService, IReceiverService { + /// + /// + /// + /// + /// public ReceiverService(IReceiverRepository repository, IMapper mapper) : base(repository, mapper) { } + /// + /// + /// + /// + /// + /// public async Task> ReadByAsync(string? emailAddress = null, string? signature = null) { var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature); @@ -26,6 +40,12 @@ public class ReceiverService : CRUDService(rcv)); } + /// + /// + /// + /// + /// + /// public async Task DeleteByAsync(string? emailAddress = null, string? signature = null) { var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature); @@ -35,16 +55,4 @@ public class ReceiverService : CRUDService UpdateAsync(TUpdateDto updateDto) - { - var val = await _repository.ReadByIdAsync(updateDto.GetId()); - if (val == null) - { - return Result.Fail().Notice(LogLevel.Warning, Flag.NotFound, $"{updateDto.GetIdOrDefault()} is not found in update process of {GetType()} entity."); - } - - var entity = _mapper.Map(updateDto, val); - return (await _repository.UpdateAsync(entity)) ? Result.Success() : Result.Fail(); - } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/UserReceiverService.cs b/EnvelopeGenerator.Application/Services/UserReceiverService.cs index 62346a0d..d4dc7b0f 100644 --- a/EnvelopeGenerator.Application/Services/UserReceiverService.cs +++ b/EnvelopeGenerator.Application/Services/UserReceiverService.cs @@ -7,8 +7,17 @@ using EnvelopeGenerator.Application.Contracts.Repositories; namespace EnvelopeGenerator.Application.Services; +/// +/// +/// +[Obsolete("Use MediatR")] public class UserReceiverService : BasicCRUDService, IUserReceiverService { + /// + /// + /// + /// + /// public UserReceiverService(IUserReceiverRepository repository, IMapper mapper) : base(repository, mapper) { diff --git a/EnvelopeGenerator.BBTests/EnvelopeGenerator.BBTests.vbproj b/EnvelopeGenerator.BBTests/EnvelopeGenerator.BBTests.vbproj index 32c8d06b..6a17d956 100644 --- a/EnvelopeGenerator.BBTests/EnvelopeGenerator.BBTests.vbproj +++ b/EnvelopeGenerator.BBTests/EnvelopeGenerator.BBTests.vbproj @@ -354,6 +354,10 @@ {6EA0C51F-C2B1-4462-8198-3DE0B32B74F8} EnvelopeGenerator.CommonServices + + {4F32A98D-E6F0-4A09-BD97-1CF26107E837} + EnvelopeGenerator.Domain + diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/AuthController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/AuthController.cs index 23b9bfdb..812ddba9 100644 --- a/EnvelopeGenerator.GeneratorAPI/Controllers/AuthController.cs +++ b/EnvelopeGenerator.GeneratorAPI/Controllers/AuthController.cs @@ -1,4 +1,4 @@ -using DigitalData.Core.Abstractions.Application; +using DigitalData.Core.Abstraction.Application; using DigitalData.UserManager.Application.Contracts; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication; diff --git a/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs b/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs index 28245c90..1633f94f 100644 --- a/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs +++ b/EnvelopeGenerator.GeneratorAPI/Controllers/HistoryController.cs @@ -5,7 +5,7 @@ using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; -using static EnvelopeGenerator.CommonServices.Constants; +using static EnvelopeGenerator.Domain.Constants; namespace EnvelopeGenerator.GeneratorAPI.Controllers; @@ -28,7 +28,7 @@ public class HistoryController : ControllerBase ///
/// Der Dienst, der für die Verarbeitung der Umschlaghistorie verantwortlich ist. /// - /// param name="mediator" + /// public HistoryController(IEnvelopeHistoryService service, IMemoryCache memoryCache, IMediator mediator) { _service = service; diff --git a/EnvelopeGenerator.GeneratorAPI/EnvelopeGenerator.GeneratorAPI.csproj b/EnvelopeGenerator.GeneratorAPI/EnvelopeGenerator.GeneratorAPI.csproj index 088c954e..e46ec6fd 100644 --- a/EnvelopeGenerator.GeneratorAPI/EnvelopeGenerator.GeneratorAPI.csproj +++ b/EnvelopeGenerator.GeneratorAPI/EnvelopeGenerator.GeneratorAPI.csproj @@ -20,16 +20,14 @@ - + - - - + diff --git a/EnvelopeGenerator.Infrastructure/EnvelopeGenerator.Infrastructure.csproj b/EnvelopeGenerator.Infrastructure/EnvelopeGenerator.Infrastructure.csproj index b7f5ea5e..10ab9e19 100644 --- a/EnvelopeGenerator.Infrastructure/EnvelopeGenerator.Infrastructure.csproj +++ b/EnvelopeGenerator.Infrastructure/EnvelopeGenerator.Infrastructure.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/EnvelopeGenerator.Infrastructure/Repositories/EmailTemplateRepository.cs b/EnvelopeGenerator.Infrastructure/Repositories/EmailTemplateRepository.cs index 836b7d98..bf2bb5ac 100644 --- a/EnvelopeGenerator.Infrastructure/Repositories/EmailTemplateRepository.cs +++ b/EnvelopeGenerator.Infrastructure/Repositories/EmailTemplateRepository.cs @@ -3,11 +3,12 @@ using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Application.Contracts.Repositories; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; -using static EnvelopeGenerator.CommonServices.Constants; +using static EnvelopeGenerator.Domain.Constants; namespace EnvelopeGenerator.Infrastructure.Repositories; - public class EmailTemplateRepository : CRUDRepository, IEmailTemplateRepository +[Obsolete("Use Repository")] +public class EmailTemplateRepository : CRUDRepository, IEmailTemplateRepository { private readonly IMemoryCache _cache; diff --git a/EnvelopeGenerator.Service/EnvelopeGenerator.Service.vbproj b/EnvelopeGenerator.Service/EnvelopeGenerator.Service.vbproj index a63270df..eae174ef 100644 --- a/EnvelopeGenerator.Service/EnvelopeGenerator.Service.vbproj +++ b/EnvelopeGenerator.Service/EnvelopeGenerator.Service.vbproj @@ -325,6 +325,10 @@ {6ea0c51f-c2b1-4462-8198-3de0b32b74f8} EnvelopeGenerator.CommonServices + + {4f32a98d-e6f0-4a09-bd97-1cf26107e837} + EnvelopeGenerator.Domain + diff --git a/EnvelopeGenerator.Service/Scheduler_Envelopetask_API.vb b/EnvelopeGenerator.Service/Scheduler_Envelopetask_API.vb index 4616fa82..59c9af5b 100644 --- a/EnvelopeGenerator.Service/Scheduler_Envelopetask_API.vb +++ b/EnvelopeGenerator.Service/Scheduler_Envelopetask_API.vb @@ -1,10 +1,9 @@ Imports System.Collections.Specialized Imports DigitalData.Modules.Base -Imports DigitalData.Modules.Database Imports DigitalData.Modules.Logging Imports EnvelopeGenerator.CommonServices.Jobs -Imports EnvelopeGenerator.CommonServices.Jobs.FinalizeDocument Imports Quartz + Public Class Scheduler_Envelopetask_API Inherits BaseClass Private Scheduler As IScheduler @@ -29,8 +28,8 @@ Public Class Scheduler_Envelopetask_API BuildScheduler() Dim oJobKey = New JobKey(JobName) Dim oJobData = New JobDataMap() From { - {Common.Constants.LOGCONFIG, LogConfig}, - {Common.Constants.DATABASE, ConnectionString} + {Domain.Constants.LOGCONFIG, LogConfig}, + {Domain.Constants.DATABASE, ConnectionString} } Logger.Debug("Initialized Job [{0}]", JobName) @@ -69,4 +68,4 @@ Public Class Scheduler_Envelopetask_API Await Scheduler.Shutdown() Logger.Info("Scheduler SendMailsfromAPI stopped!") End Function -End Class +End Class \ No newline at end of file diff --git a/EnvelopeGenerator.Service/Scheduler_FinishEnvelope.vb b/EnvelopeGenerator.Service/Scheduler_FinishEnvelope.vb index 7293dd07..50dd4675 100644 --- a/EnvelopeGenerator.Service/Scheduler_FinishEnvelope.vb +++ b/EnvelopeGenerator.Service/Scheduler_FinishEnvelope.vb @@ -1,6 +1,5 @@ Imports System.Collections.Specialized Imports DigitalData.Modules.Base -Imports DigitalData.Modules.Database Imports DigitalData.Modules.Logging Imports EnvelopeGenerator.CommonServices.Jobs Imports EnvelopeGenerator.CommonServices.Jobs.FinalizeDocument @@ -38,10 +37,10 @@ Public Class Scheduler_FinishEnvelope Dim oJobKey = New JobKey(JobName) Dim oJobData = New JobDataMap() From { - {Common.Constants.GDPICTURE, LicenseKey}, - {Common.Constants.LOGCONFIG, LogConfig}, - {Common.Constants.DATABASE, ConnectionString}, - {Common.Constants.PDF_BURNER_PARAMS, _pdfBurnerParams} + {Domain.Constants.GDPICTURE, LicenseKey}, + {Domain.Constants.LOGCONFIG, LogConfig}, + {Domain.Constants.DATABASE, ConnectionString}, + {Domain.Constants.PDF_BURNER_PARAMS, _pdfBurnerParams} } Logger.Debug("Initialized Job [{0}]", JobName) diff --git a/EnvelopeGenerator.Terminal/EnvelopeGenerator.Terminal.csproj b/EnvelopeGenerator.Terminal/EnvelopeGenerator.Terminal.csproj index cc3df0bd..7637a308 100644 --- a/EnvelopeGenerator.Terminal/EnvelopeGenerator.Terminal.csproj +++ b/EnvelopeGenerator.Terminal/EnvelopeGenerator.Terminal.csproj @@ -19,8 +19,6 @@ - - diff --git a/EnvelopeGenerator.Tests.Application/EnvelopeGenerator.Tests.Application.csproj b/EnvelopeGenerator.Tests.Application/EnvelopeGenerator.Tests.Application.csproj index c50134be..898a6dd0 100644 --- a/EnvelopeGenerator.Tests.Application/EnvelopeGenerator.Tests.Application.csproj +++ b/EnvelopeGenerator.Tests.Application/EnvelopeGenerator.Tests.Application.csproj @@ -23,9 +23,10 @@ + - - + + diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestControllerBase.cs b/EnvelopeGenerator.Web/Controllers/Test/TestControllerBase.cs index 9e81ac1f..0f23b8bf 100644 --- a/EnvelopeGenerator.Web/Controllers/Test/TestControllerBase.cs +++ b/EnvelopeGenerator.Web/Controllers/Test/TestControllerBase.cs @@ -1,5 +1,5 @@ using DigitalData.Core.API; -using DigitalData.Core.Abstractions.Application; +using DigitalData.Core.Abstraction.Application; using Microsoft.AspNetCore.Mvc; using DigitalData.Core.Abstractions; diff --git a/EnvelopeGenerator.Web/EnvelopeGenerator.Web.csproj b/EnvelopeGenerator.Web/EnvelopeGenerator.Web.csproj index 0eafa530..4f22a610 100644 --- a/EnvelopeGenerator.Web/EnvelopeGenerator.Web.csproj +++ b/EnvelopeGenerator.Web/EnvelopeGenerator.Web.csproj @@ -2101,10 +2101,8 @@ - - - - + +