Merge branch 'master' of http://git.dd:3000/AppStd/EnvelopeGenerator
This commit is contained in:
commit
ab5fdbd41e
@ -0,0 +1,5 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Configurations;
|
||||||
|
|
||||||
|
public class DbTriggerParams : Dictionary<string, IEnumerable<string>>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -1,19 +0,0 @@
|
|||||||
using OtpNet;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IConfigService : IReadService<ConfigDto, Config, int>
|
|
||||||
{
|
|
||||||
Task<DataResult<ConfigDto>> ReadFirstAsync();
|
|
||||||
|
|
||||||
Task<ConfigDto> ReadDefaultAsync();
|
|
||||||
|
|
||||||
Task<string> ReadDefaultSignatureHost();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IDocumentReceiverElementService : IBasicCRUDService<DocumentReceiverElementDto, DocumentReceiverElement, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IDocumentStatusService : IBasicCRUDService<DocumentStatusDto, DocumentStatus, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
using static EnvelopeGenerator.Common.Constants;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEmailTemplateService : IBasicCRUDService<EmailTemplateDto, EmailTemplate, int>
|
|
||||||
{
|
|
||||||
Task<DataResult<EmailTemplateDto>> ReadByNameAsync(EmailTemplateType type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeCertificateService : IBasicCRUDService<EnvelopeCertificateDto, EnvelopeCertificate, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeDocumentService : IBasicCRUDService<EnvelopeDocumentDto, EnvelopeDocument, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
using static EnvelopeGenerator.Common.Constants;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeHistoryService : ICRUDService<EnvelopeHistoryCreateDto, EnvelopeHistoryDto, EnvelopeHistoryDto, EnvelopeHistory, long>
|
|
||||||
{
|
|
||||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
|
|
||||||
|
|
||||||
Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference);
|
|
||||||
|
|
||||||
Task<bool> IsSigned(int envelopeId, string userReference);
|
|
||||||
|
|
||||||
Task<bool> IsRejected(int envelopeId, string? userReference = null);
|
|
||||||
|
|
||||||
Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false);
|
|
||||||
|
|
||||||
Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null);
|
|
||||||
|
|
||||||
Task<IEnumerable<ReceiverReadDto>> ReadRejectingReceivers(int envelopeId);
|
|
||||||
|
|
||||||
Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
using DigitalData.Core.DTO;
|
|
||||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Contracts;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
|
||||||
using EnvelopeGenerator.Common;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeMailService : IEmailOutService
|
|
||||||
{
|
|
||||||
Task<DataResult<int>> SendAsync(EnvelopeReceiverDto envelopeReceiverDto, Constants.EmailTemplateType tempType, Dictionary<string, object>? optionalPlaceholders = null);
|
|
||||||
|
|
||||||
Task<DataResult<int>> SendAsync(EnvelopeReceiverReadOnlyDto dto, Dictionary<string, object>? optionalPlaceholders = null);
|
|
||||||
|
|
||||||
Task<DataResult<int>> SendAccessCodeAsync(EnvelopeReceiverDto envelopeReceiverDto);
|
|
||||||
|
|
||||||
Task<DataResult<int>> SendTFAQrCodeAsync(EnvelopeReceiverDto envelopeReceiverDto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeReceiverReadOnlyService : ICRUDService<EnvelopeReceiverReadOnlyCreateDto, EnvelopeReceiverReadOnlyDto, EnvelopeReceiverReadOnlyUpdateDto, EnvelopeReceiverReadOnly, long>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeReceiverService : IBasicCRUDService<EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>
|
|
||||||
{
|
|
||||||
|
|
||||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<DataResult<IEnumerable<string?>>> ReadAccessCodeByUuidAsync(string uuid, bool withEnvelope = false, bool withReceiver = true);
|
|
||||||
|
|
||||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<DataResult<EnvelopeReceiverDto>> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<DataResult<EnvelopeReceiverSecretDto>> ReadWithSecretByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<DataResult<EnvelopeReceiverDto>> ReadByEnvelopeReceiverIdAsync(string envelopeReceiverId, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<DataResult<string>> ReadAccessCodeByIdAsync(int envelopeId, int receiverId);
|
|
||||||
|
|
||||||
Task<DataResult<bool>> VerifyAccessCodeAsync(string uuid, string signature, string accessCode);
|
|
||||||
|
|
||||||
Task<DataResult<bool>> VerifyAccessCodeAsync(string envelopeReceiverId, string accessCode);
|
|
||||||
|
|
||||||
Task<DataResult<bool>> IsExisting(string envelopeReceiverId);
|
|
||||||
|
|
||||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
|
||||||
|
|
||||||
Task<DataResult<string?>> ReadLastUsedReceiverNameByMail(string mail);
|
|
||||||
|
|
||||||
Task<DataResult<SmsResponse>> SendSmsAsync(string envelopeReceiverId, string message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeService : IBasicCRUDService<EnvelopeDto, Envelope, int>
|
|
||||||
{
|
|
||||||
Task<DataResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false);
|
|
||||||
|
|
||||||
Task<DataResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false);
|
|
||||||
|
|
||||||
Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[]ignore_statuses);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeTypeService : IBasicCRUDService<EnvelopeTypeDto, EnvelopeType, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions;
|
|
||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IReceiverService : ICRUDService<ReceiverCreateDto, ReceiverReadDto, ReceiverUpdateDto, Receiver, int>
|
|
||||||
{
|
|
||||||
Task<DataResult<ReceiverReadDto>> ReadByAsync(string? emailAddress = null, string? signature = null);
|
|
||||||
|
|
||||||
Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null);
|
|
||||||
|
|
||||||
Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto) where TUpdateDto : IUnique<int>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Application;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts
|
|
||||||
{
|
|
||||||
public interface IUserReceiverService : IBasicCRUDService<UserReceiverDto, UserReceiver, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IConfigRepository : ICRUDRepository<Config, int>
|
||||||
|
{
|
||||||
|
Task<Config?> ReadFirstAsync();
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IDocumentReceiverElementRepository : ICRUDRepository<DocumentReceiverElement, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IDocumentStatusRepository : ICRUDRepository<DocumentStatus, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using static EnvelopeGenerator.Common.Constants;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IEmailTemplateRepository : ICRUDRepository<EmailTemplate, int>
|
||||||
|
{
|
||||||
|
Task<EmailTemplate?> ReadByNameAsync(EmailTemplateType type);
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IEnvelopeCertificateRepository : ICRUDRepository<EnvelopeCertificate, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IEnvelopeDocumentRepository : ICRUDRepository<EnvelopeDocument, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, long>
|
||||||
|
{
|
||||||
|
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
|
||||||
|
|
||||||
|
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false);
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IEnvelopeReceiverReadOnlyRepository : ICRUDRepository<EnvelopeReceiverReadOnly, long>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IEnvelopeReceiverRepository : ICRUDRepository<EnvelopeReceiver, (int Envelope, int Receiver)>
|
||||||
|
{
|
||||||
|
Task<IEnumerable<EnvelopeReceiver>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<IEnumerable<EnvelopeReceiver>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<EnvelopeReceiver?> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<string?> ReadAccessCodeAsync(string uuid, string signature, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<int> CountAsync(string uuid, string signature);
|
||||||
|
|
||||||
|
Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||||
|
|
||||||
|
Task<EnvelopeReceiver?> ReadLastByReceiver(string email);
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IEnvelopeRepository : ICRUDRepository<Envelope, int>
|
||||||
|
{
|
||||||
|
Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false);
|
||||||
|
|
||||||
|
Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false);
|
||||||
|
|
||||||
|
Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IEnvelopeTypeRepository : ICRUDRepository<EnvelopeType, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IReceiverRepository : ICRUDRepository<Receiver, int>
|
||||||
|
{
|
||||||
|
Task<Receiver?> ReadByAsync(string? emailAddress = null, string? signature = null);
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
|
public interface IUserReceiverRepository : ICRUDRepository<UserReceiver, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
using OtpNet;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IConfigService : IReadService<ConfigDto, Config, int>
|
||||||
|
{
|
||||||
|
Task<DataResult<ConfigDto>> ReadFirstAsync();
|
||||||
|
|
||||||
|
Task<ConfigDto> ReadDefaultAsync();
|
||||||
|
|
||||||
|
Task<string> ReadDefaultSignatureHost();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IDocumentReceiverElementService : IBasicCRUDService<DocumentReceiverElementDto, DocumentReceiverElement, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IDocumentStatusService : IBasicCRUDService<DocumentStatusDto, DocumentStatus, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using static EnvelopeGenerator.Common.Constants;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEmailTemplateService : IBasicCRUDService<EmailTemplateDto, EmailTemplate, int>
|
||||||
|
{
|
||||||
|
Task<DataResult<EmailTemplateDto>> ReadByNameAsync(EmailTemplateType type);
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEnvelopeCertificateService : IBasicCRUDService<EnvelopeCertificateDto, EnvelopeCertificate, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEnvelopeDocumentService : IBasicCRUDService<EnvelopeDocumentDto, EnvelopeDocument, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using static EnvelopeGenerator.Common.Constants;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEnvelopeHistoryService : ICRUDService<EnvelopeHistoryCreateDto, EnvelopeHistoryDto, EnvelopeHistoryDto, EnvelopeHistory, long>
|
||||||
|
{
|
||||||
|
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
|
||||||
|
|
||||||
|
Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference);
|
||||||
|
|
||||||
|
Task<bool> IsSigned(int envelopeId, string userReference);
|
||||||
|
|
||||||
|
Task<bool> IsRejected(int envelopeId, string? userReference = null);
|
||||||
|
|
||||||
|
Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false);
|
||||||
|
|
||||||
|
Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null);
|
||||||
|
|
||||||
|
Task<IEnumerable<ReceiverReadDto>> ReadRejectingReceivers(int envelopeId);
|
||||||
|
|
||||||
|
Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null);
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using DigitalData.EmailProfilerDispatcher.Abstraction.Contracts;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||||
|
using EnvelopeGenerator.Common;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEnvelopeMailService : IEmailOutService
|
||||||
|
{
|
||||||
|
Task<DataResult<int>> SendAsync(EnvelopeReceiverDto envelopeReceiverDto, Constants.EmailTemplateType tempType, Dictionary<string, object>? optionalPlaceholders = null);
|
||||||
|
|
||||||
|
Task<DataResult<int>> SendAsync(EnvelopeReceiverReadOnlyDto dto, Dictionary<string, object>? optionalPlaceholders = null);
|
||||||
|
|
||||||
|
Task<DataResult<int>> SendAccessCodeAsync(EnvelopeReceiverDto envelopeReceiverDto);
|
||||||
|
|
||||||
|
Task<DataResult<int>> SendTFAQrCodeAsync(EnvelopeReceiverDto envelopeReceiverDto);
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEnvelopeReceiverReadOnlyService : ICRUDService<EnvelopeReceiverReadOnlyCreateDto, EnvelopeReceiverReadOnlyDto, EnvelopeReceiverReadOnlyUpdateDto, EnvelopeReceiverReadOnly, long>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEnvelopeReceiverService : IBasicCRUDService<EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>
|
||||||
|
{
|
||||||
|
|
||||||
|
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<DataResult<IEnumerable<string?>>> ReadAccessCodeByUuidAsync(string uuid, bool withEnvelope = false, bool withReceiver = true);
|
||||||
|
|
||||||
|
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<DataResult<EnvelopeReceiverDto>> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<DataResult<EnvelopeReceiverSecretDto>> ReadWithSecretByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<DataResult<EnvelopeReceiverDto>> ReadByEnvelopeReceiverIdAsync(string envelopeReceiverId, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true);
|
||||||
|
|
||||||
|
Task<DataResult<string>> ReadAccessCodeByIdAsync(int envelopeId, int receiverId);
|
||||||
|
|
||||||
|
Task<DataResult<bool>> VerifyAccessCodeAsync(string uuid, string signature, string accessCode);
|
||||||
|
|
||||||
|
Task<DataResult<bool>> VerifyAccessCodeAsync(string envelopeReceiverId, string accessCode);
|
||||||
|
|
||||||
|
Task<DataResult<bool>> IsExisting(string envelopeReceiverId);
|
||||||
|
|
||||||
|
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||||
|
|
||||||
|
Task<DataResult<string?>> ReadLastUsedReceiverNameByMail(string mail);
|
||||||
|
|
||||||
|
Task<DataResult<SmsResponse>> SendSmsAsync(string envelopeReceiverId, string message);
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEnvelopeService : IBasicCRUDService<EnvelopeDto, Envelope, int>
|
||||||
|
{
|
||||||
|
Task<DataResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false);
|
||||||
|
|
||||||
|
Task<DataResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false);
|
||||||
|
|
||||||
|
Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts;
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
public interface IEnvelopeSmsHandler
|
public interface IEnvelopeSmsHandler
|
||||||
{
|
{
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IEnvelopeTypeService : IBasicCRUDService<EnvelopeTypeDto, EnvelopeType, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
using DigitalData.Core.Abstractions;
|
||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IReceiverService : ICRUDService<ReceiverCreateDto, ReceiverReadDto, ReceiverUpdateDto, Receiver, int>
|
||||||
|
{
|
||||||
|
Task<DataResult<ReceiverReadDto>> ReadByAsync(string? emailAddress = null, string? signature = null);
|
||||||
|
|
||||||
|
Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null);
|
||||||
|
|
||||||
|
Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto) where TUpdateDto : IUnique<int>;
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Contracts;
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
//TODO: move to DigitalData.Core
|
//TODO: move to DigitalData.Core
|
||||||
public interface ISmsSender
|
public interface ISmsSender
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
using DigitalData.Core.Abstractions.Application;
|
||||||
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
|
public interface IUserReceiverService : IBasicCRUDService<UserReceiverDto, UserReceiver, int>
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -26,8 +26,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj" />
|
||||||
<ProjectReference Include="..\EnvelopeGenerator.Extensions\EnvelopeGenerator.Extensions.csproj" />
|
<ProjectReference Include="..\EnvelopeGenerator.Extensions\EnvelopeGenerator.Extensions.csproj" />
|
||||||
<ProjectReference Include="..\EnvelopeGenerator.Infrastructure\EnvelopeGenerator.Infrastructure.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -1,39 +1,21 @@
|
|||||||
using DigitalData.UserManager.Application.MappingProfiles;
|
using DigitalData.UserManager.Application.MappingProfiles;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
|
||||||
using EnvelopeGenerator.Application.MappingProfiles;
|
using EnvelopeGenerator.Application.MappingProfiles;
|
||||||
using EnvelopeGenerator.Application.Configurations;
|
using EnvelopeGenerator.Application.Configurations;
|
||||||
using EnvelopeGenerator.Application.Services;
|
using EnvelopeGenerator.Application.Services;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
|
||||||
using EnvelopeGenerator.Infrastructure.Repositories;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using DigitalData.Core.Client;
|
using DigitalData.Core.Client;
|
||||||
using QRCoder;
|
using QRCoder;
|
||||||
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Extensions;
|
namespace EnvelopeGenerator.Application.Extensions;
|
||||||
|
|
||||||
public static class DIExtensions
|
public static class DIExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddEnvelopeGenerator(this IServiceCollection services, IConfiguration config)
|
public static IServiceCollection AddEnvelopeGeneratorServices(this IServiceCollection services, IConfiguration config)
|
||||||
{
|
{
|
||||||
//Inject CRUD Service and repositoriesad
|
//Inject CRUD Service and repositoriesad
|
||||||
services.TryAddScoped<IConfigRepository, ConfigRepository>();
|
|
||||||
services.TryAddScoped<IDocumentReceiverElementRepository, DocumentReceiverElementRepository>();
|
|
||||||
services.TryAddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
|
|
||||||
services.TryAddScoped<IConfigRepository, ConfigRepository>();
|
|
||||||
services.TryAddScoped<IDocumentReceiverElementRepository, DocumentReceiverElementRepository>();
|
|
||||||
services.TryAddScoped<IDocumentStatusRepository, DocumentStatusRepository>();
|
|
||||||
services.TryAddScoped<IEmailTemplateRepository, EmailTemplateRepository>();
|
|
||||||
services.TryAddScoped<IEnvelopeRepository, EnvelopeRepository>();
|
|
||||||
services.TryAddScoped<IEnvelopeCertificateRepository, EnvelopeCertificateRepository>();
|
|
||||||
services.TryAddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
|
|
||||||
services.TryAddScoped<IEnvelopeHistoryRepository, EnvelopeHistoryRepository>();
|
|
||||||
services.TryAddScoped<IEnvelopeReceiverRepository, EnvelopeReceiverRepository>();
|
|
||||||
services.TryAddScoped<IEnvelopeTypeRepository, EnvelopeTypeRepository>();
|
|
||||||
services.TryAddScoped<IReceiverRepository, ReceiverRepository>();
|
|
||||||
services.TryAddScoped<IUserReceiverRepository, UserReceiverRepository>();
|
|
||||||
services.TryAddScoped<IEnvelopeReceiverReadOnlyRepository, EnvelopeReceiverReadOnlyRepository>();
|
|
||||||
services.TryAddScoped<IConfigService, ConfigService>();
|
services.TryAddScoped<IConfigService, ConfigService>();
|
||||||
services.TryAddScoped<IDocumentReceiverElementService, DocumentReceiverElementService>();
|
services.TryAddScoped<IDocumentReceiverElementService, DocumentReceiverElementService>();
|
||||||
services.TryAddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
|
services.TryAddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
|
||||||
@ -57,6 +39,7 @@ public static class DIExtensions
|
|||||||
services.Configure<MailParams>(config.GetSection(nameof(MailParams)));
|
services.Configure<MailParams>(config.GetSection(nameof(MailParams)));
|
||||||
services.Configure<AuthenticatorParams>(config.GetSection(nameof(AuthenticatorParams)));
|
services.Configure<AuthenticatorParams>(config.GetSection(nameof(AuthenticatorParams)));
|
||||||
services.Configure<TotpSmsParams>(config.GetSection(nameof(TotpSmsParams)));
|
services.Configure<TotpSmsParams>(config.GetSection(nameof(TotpSmsParams)));
|
||||||
|
services.Configure<DbTriggerParams>(config.GetSection(nameof(DbTriggerParams)));
|
||||||
|
|
||||||
services.AddHttpClientService<GtxMessagingParams>(config.GetSection(nameof(GtxMessagingParams)));
|
services.AddHttpClientService<GtxMessagingParams>(config.GetSection(nameof(GtxMessagingParams)));
|
||||||
services.TryAddSingleton<ISmsSender, GTXSmsSender>();
|
services.TryAddSingleton<ISmsSender, GTXSmsSender>();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
using EnvelopeGenerator.Application.Configurations;
|
using EnvelopeGenerator.Application.Configurations;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using OtpNet;
|
using OtpNet;
|
||||||
using QRCoder;
|
using QRCoder;
|
||||||
|
|||||||
@ -1,33 +1,33 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class ConfigService : ReadService<IConfigRepository, ConfigDto, Config, int>, IConfigService
|
||||||
{
|
{
|
||||||
public class ConfigService : ReadService<IConfigRepository, ConfigDto, Config, int>, 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<ConfigService> _logger;
|
private readonly ILogger<ConfigService> _logger;
|
||||||
public ConfigService(IConfigRepository repository, IMapper mapper, IMemoryCache memoryCache, ILogger<ConfigService> logger) : base(repository, mapper)
|
public ConfigService(IConfigRepository repository, IMapper mapper, IMemoryCache memoryCache, ILogger<ConfigService> logger) : base(repository, mapper)
|
||||||
{
|
{
|
||||||
_cache = memoryCache;
|
_cache = memoryCache;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<ConfigDto>> ReadFirstAsync()
|
public async Task<DataResult<ConfigDto>> ReadFirstAsync()
|
||||||
{
|
{
|
||||||
var config = await _repository.ReadFirstAsync();
|
var config = await _repository.ReadFirstAsync();
|
||||||
return config is null
|
return config is null
|
||||||
? Result.Fail<ConfigDto>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, "There is no configuration in DB.")
|
? Result.Fail<ConfigDto>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, "There is no configuration in DB.")
|
||||||
: Result.Success(_mapper.Map<ConfigDto>(config));
|
: Result.Success(_mapper.Map<ConfigDto>(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads the default configuration asynchronously.
|
/// Reads the default configuration asynchronously.
|
||||||
@ -43,18 +43,17 @@ namespace EnvelopeGenerator.Application.Services
|
|||||||
/// Thrown when the default configuration cannot be found.
|
/// Thrown when the default configuration cannot be found.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public async Task<ConfigDto> ReadDefaultAsync()
|
public async Task<ConfigDto> ReadDefaultAsync()
|
||||||
{
|
{
|
||||||
var config = await _cache.GetOrCreateAsync(DefaultConfigCacheId, _ => ReadFirstAsync().ThenAsync(
|
var config = await _cache.GetOrCreateAsync(DefaultConfigCacheId, _ => ReadFirstAsync().ThenAsync(
|
||||||
Success: config => config,
|
Success: config => config,
|
||||||
Fail: (mssg, ntc) =>
|
Fail: (mssg, ntc) =>
|
||||||
{
|
{
|
||||||
_logger.LogNotice(ntc);
|
_logger.LogNotice(ntc);
|
||||||
throw new InvalidOperationException("Default configuration cannot find.");
|
throw new InvalidOperationException("Default configuration cannot find.");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return config!;
|
return config!;
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> ReadDefaultSignatureHost() => (await ReadDefaultAsync()).SignatureHost;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<string> ReadDefaultSignatureHost() => (await ReadDefaultAsync()).SignatureHost;
|
||||||
}
|
}
|
||||||
@ -1,17 +1,16 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class DocumentReceiverElementService : BasicCRUDService<IDocumentReceiverElementRepository, DocumentReceiverElementDto, DocumentReceiverElement, int>, IDocumentReceiverElementService
|
||||||
{
|
{
|
||||||
public class DocumentReceiverElementService : BasicCRUDService<IDocumentReceiverElementRepository, DocumentReceiverElementDto, DocumentReceiverElement, int>, IDocumentReceiverElementService
|
public DocumentReceiverElementService(IDocumentReceiverElementRepository repository, IMapper mapper)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
public DocumentReceiverElementService(IDocumentReceiverElementRepository repository, IMapper mapper)
|
|
||||||
: base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,17 +1,16 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class DocumentStatusService : BasicCRUDService<IDocumentStatusRepository, DocumentStatusDto, DocumentStatus, int>, IDocumentStatusService
|
||||||
{
|
{
|
||||||
public class DocumentStatusService : BasicCRUDService<IDocumentStatusRepository, DocumentStatusDto, DocumentStatus, int>, IDocumentStatusService
|
public DocumentStatusService(IDocumentStatusRepository repository, IMapper mapper)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
public DocumentStatusService(IDocumentStatusRepository repository, IMapper mapper)
|
|
||||||
: base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,30 +1,29 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using static EnvelopeGenerator.Common.Constants;
|
using static EnvelopeGenerator.Common.Constants;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class EmailTemplateService : BasicCRUDService<IEmailTemplateRepository, EmailTemplateDto, EmailTemplate, int>, IEmailTemplateService
|
||||||
{
|
{
|
||||||
public class EmailTemplateService : BasicCRUDService<IEmailTemplateRepository, EmailTemplateDto, EmailTemplate, int>, IEmailTemplateService
|
public EmailTemplateService(IEmailTemplateRepository repository, IMapper mapper)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
public EmailTemplateService(IEmailTemplateRepository repository, IMapper mapper)
|
}
|
||||||
: base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<DataResult<EmailTemplateDto>> ReadByNameAsync(EmailTemplateType type)
|
public async Task<DataResult<EmailTemplateDto>> ReadByNameAsync(EmailTemplateType type)
|
||||||
{
|
{
|
||||||
var temp = await _repository.ReadByNameAsync(type);
|
var temp = await _repository.ReadByNameAsync(type);
|
||||||
return temp is null
|
return temp is null
|
||||||
? Result.Fail<EmailTemplateDto>()
|
? Result.Fail<EmailTemplateDto>()
|
||||||
.Message(Key.InnerServiceError)
|
.Message(Key.InnerServiceError)
|
||||||
.Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"EmailTemplateType '{type}' is not found in DB. Please, define required e-mail template.")
|
.Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"EmailTemplateType '{type}' is not found in DB. Please, define required e-mail template.")
|
||||||
: Result.Success(_mapper.Map<EmailTemplateDto>(temp));
|
: Result.Success(_mapper.Map<EmailTemplateDto>(temp));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,19 +1,17 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using EnvelopeGenerator.Application.Resources;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class EnvelopeCertificateService : BasicCRUDService<IEnvelopeCertificateRepository, EnvelopeCertificateDto, EnvelopeCertificate, int>, IEnvelopeCertificateService
|
||||||
{
|
{
|
||||||
public class EnvelopeCertificateService : BasicCRUDService<IEnvelopeCertificateRepository, EnvelopeCertificateDto, EnvelopeCertificate, int>, IEnvelopeCertificateService
|
public EnvelopeCertificateService(IEnvelopeCertificateRepository repository, IMapper mapper)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
public EnvelopeCertificateService(IEnvelopeCertificateRepository repository, IMapper mapper)
|
|
||||||
: base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,16 +1,15 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class EnvelopeDocumentService : BasicCRUDService<IEnvelopeDocumentRepository, EnvelopeDocumentDto, EnvelopeDocument, int>, IEnvelopeDocumentService
|
||||||
{
|
{
|
||||||
public class EnvelopeDocumentService : BasicCRUDService<IEnvelopeDocumentRepository, EnvelopeDocumentDto, EnvelopeDocument, int>, IEnvelopeDocumentService
|
public EnvelopeDocumentService(IEnvelopeDocumentRepository repository, IMapper mapper) : base(repository, mapper)
|
||||||
{
|
{
|
||||||
public EnvelopeDocumentService(IEnvelopeDocumentRepository repository, IMapper mapper) : base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,85 +1,84 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using static EnvelopeGenerator.Common.Constants;
|
using static EnvelopeGenerator.Common.Constants;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
||||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||||
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, EnvelopeHistoryCreateDto, EnvelopeHistoryDto, EnvelopeHistoryDto, EnvelopeHistory, long>, IEnvelopeHistoryService
|
||||||
{
|
{
|
||||||
public class EnvelopeHistoryService : CRUDService<IEnvelopeHistoryRepository, EnvelopeHistoryCreateDto, EnvelopeHistoryDto, EnvelopeHistoryDto, EnvelopeHistory, long>, IEnvelopeHistoryService
|
public EnvelopeHistoryService(IEnvelopeHistoryRepository repository, IMapper mapper)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
public EnvelopeHistoryService(IEnvelopeHistoryRepository repository, IMapper mapper)
|
}
|
||||||
: base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await _repository.CountAsync(envelopeId: envelopeId, userReference: userReference, status: status);
|
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await _repository.CountAsync(envelopeId: envelopeId, userReference: userReference, status: status);
|
||||||
|
|
||||||
public async Task<bool> HasStatus(EnvelopeStatus status, int envelopeId, string userReference) => await _repository.CountAsync(
|
public async Task<bool> HasStatus(EnvelopeStatus status, int envelopeId, string userReference) => await _repository.CountAsync(
|
||||||
|
envelopeId: envelopeId,
|
||||||
|
userReference: userReference,
|
||||||
|
status: (int) status) > 0;
|
||||||
|
|
||||||
|
public async Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync(
|
||||||
|
envelopeId: envelopeId,
|
||||||
|
userReference:userReference,
|
||||||
|
status: (int) EnvelopeStatus.AccessCodeRequested) > 0;
|
||||||
|
|
||||||
|
public async Task<bool> IsSigned(int envelopeId, string userReference) => await _repository.CountAsync(
|
||||||
|
envelopeId: envelopeId,
|
||||||
|
userReference: userReference,
|
||||||
|
status: (int) EnvelopeStatus.DocumentSigned) > 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the specified envelope has been rejected.
|
||||||
|
/// <para><b>Note:</b> <i>If any document within the envelope is rejected, the entire envelope will be considered rejected.</i></para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="envelopeId">The ID of the envelope to check.</param>
|
||||||
|
/// <param name="userReference">Optional user reference associated with the envelope.</param>
|
||||||
|
/// <returns>A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the envelope is rejected.</returns>
|
||||||
|
public async Task<bool> IsRejected(int envelopeId, string? userReference = null)
|
||||||
|
{
|
||||||
|
return await _repository.CountAsync(
|
||||||
envelopeId: envelopeId,
|
envelopeId: envelopeId,
|
||||||
userReference: userReference,
|
userReference: userReference,
|
||||||
status: (int) status) > 0;
|
status: (int)EnvelopeStatus.DocumentRejected) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> AccessCodeAlreadyRequested(int envelopeId, string userReference) => await _repository.CountAsync(
|
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
||||||
envelopeId: envelopeId,
|
{
|
||||||
userReference:userReference,
|
var histDTOs = _mapper.Map<IEnumerable<EnvelopeHistoryDto>>(
|
||||||
status: (int) EnvelopeStatus.AccessCodeRequested) > 0;
|
await _repository.ReadAsync(
|
||||||
|
envelopeId: envelopeId,
|
||||||
|
userReference: userReference,
|
||||||
|
status: status,
|
||||||
|
withSender: withSender,
|
||||||
|
withReceiver: withReceiver));
|
||||||
|
return referenceType is null ? histDTOs : histDTOs.Where(h => h.ReferenceType == referenceType);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> IsSigned(int envelopeId, string userReference) => await _repository.CountAsync(
|
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null) =>
|
||||||
envelopeId: envelopeId,
|
await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: (int)EnvelopeStatus.DocumentRejected, withReceiver:true);
|
||||||
userReference: userReference,
|
|
||||||
status: (int) EnvelopeStatus.DocumentSigned) > 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks if the specified envelope has been rejected.
|
|
||||||
/// <para><b>Note:</b> <i>If any document within the envelope is rejected, the entire envelope will be considered rejected.</i></para>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="envelopeId">The ID of the envelope to check.</param>
|
|
||||||
/// <param name="userReference">Optional user reference associated with the envelope.</param>
|
|
||||||
/// <returns>A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the envelope is rejected.</returns>
|
|
||||||
public async Task<bool> IsRejected(int envelopeId, string? userReference = null)
|
|
||||||
{
|
|
||||||
return await _repository.CountAsync(
|
|
||||||
envelopeId: envelopeId,
|
|
||||||
userReference: userReference,
|
|
||||||
status: (int)EnvelopeStatus.DocumentRejected) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadAsync(int? envelopeId = null, string? userReference = null, ReferenceType? referenceType = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
|
||||||
{
|
|
||||||
var histDTOs = _mapper.Map<IEnumerable<EnvelopeHistoryDto>>(
|
|
||||||
await _repository.ReadAsync(
|
|
||||||
envelopeId: envelopeId,
|
|
||||||
userReference: userReference,
|
|
||||||
status: status,
|
|
||||||
withSender: withSender,
|
|
||||||
withReceiver: withReceiver));
|
|
||||||
return referenceType is null ? histDTOs : histDTOs.Where(h => h.ReferenceType == referenceType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<EnvelopeHistoryDto>> 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
|
//TODO: use IQueryable in repository to incerease the performance
|
||||||
public async Task<IEnumerable<ReceiverReadDto>> ReadRejectingReceivers(int envelopeId)
|
public async Task<IEnumerable<ReceiverReadDto>> ReadRejectingReceivers(int envelopeId)
|
||||||
{
|
{
|
||||||
var envelopes = await ReadRejectedAsync(envelopeId);
|
var envelopes = await ReadRejectedAsync(envelopeId);
|
||||||
return envelopes is null
|
return envelopes is null
|
||||||
? Enumerable.Empty<ReceiverReadDto>()
|
? Enumerable.Empty<ReceiverReadDto>()
|
||||||
: envelopes
|
: envelopes
|
||||||
.Where(eh => eh?.Receiver != null)
|
.Where(eh => eh?.Receiver != null)
|
||||||
.Select(eh => eh.Receiver!);
|
.Select(eh => eh.Receiver!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null) =>
|
public async Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null) =>
|
||||||
await CreateAsync(new (EnvelopeId: envelopeId, UserReference: userReference, Status: (int)status, ActionDate: DateTime.Now, Comment: comment))
|
await CreateAsync(new (EnvelopeId: envelopeId, UserReference: userReference, Status: (int)status, ActionDate: DateTime.Now, Comment: comment))
|
||||||
.ThenAsync(
|
.ThenAsync(
|
||||||
Success: id => Result.Success(id),
|
Success: id => Result.Success(id),
|
||||||
Fail: (mssg, ntc) => Result.Fail<long>().Message(mssg).Notice(ntc)
|
Fail: (mssg, ntc) => Result.Fail<long>().Message(mssg).Notice(ntc)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -3,7 +3,6 @@ using DigitalData.Core.DTO;
|
|||||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Contracts;
|
using DigitalData.EmailProfilerDispatcher.Abstraction.Contracts;
|
||||||
using DigitalData.EmailProfilerDispatcher.Abstraction.DTOs.EmailOut;
|
using DigitalData.EmailProfilerDispatcher.Abstraction.DTOs.EmailOut;
|
||||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Services;
|
using DigitalData.EmailProfilerDispatcher.Abstraction.Services;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
using EnvelopeGenerator.Common;
|
using EnvelopeGenerator.Common;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -14,6 +13,7 @@ using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
|||||||
using EnvelopeGenerator.Application.Configurations;
|
using EnvelopeGenerator.Application.Configurations;
|
||||||
using EnvelopeGenerator.Application.Extensions;
|
using EnvelopeGenerator.Application.Extensions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,16 +1,15 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class EnvelopeReceiverReadOnlyService : CRUDService<IEnvelopeReceiverReadOnlyRepository, EnvelopeReceiverReadOnlyCreateDto, EnvelopeReceiverReadOnlyDto, EnvelopeReceiverReadOnlyUpdateDto, EnvelopeReceiverReadOnly, long>, IEnvelopeReceiverReadOnlyService
|
||||||
{
|
{
|
||||||
public class EnvelopeReceiverReadOnlyService : CRUDService<IEnvelopeReceiverReadOnlyRepository, EnvelopeReceiverReadOnlyCreateDto, EnvelopeReceiverReadOnlyDto, EnvelopeReceiverReadOnlyUpdateDto, EnvelopeReceiverReadOnly, long>, IEnvelopeReceiverReadOnlyService
|
public EnvelopeReceiverReadOnlyService(IEnvelopeReceiverReadOnlyRepository repository, IMapper mapper) : base(repository, mapper)
|
||||||
{
|
{
|
||||||
public EnvelopeReceiverReadOnlyService(IEnvelopeReceiverReadOnlyRepository repository, IMapper mapper) : base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,179 +1,178 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
using EnvelopeGenerator.Application.Resources;
|
using EnvelopeGenerator.Application.Resources;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using EnvelopeGenerator.Extensions;
|
using EnvelopeGenerator.Extensions;
|
||||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||||
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class EnvelopeReceiverService : BasicCRUDService<IEnvelopeReceiverRepository, EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>, IEnvelopeReceiverService
|
||||||
{
|
{
|
||||||
public class EnvelopeReceiverService : BasicCRUDService<IEnvelopeReceiverRepository, EnvelopeReceiverDto, EnvelopeReceiver, (int Envelope, int Receiver)>, IEnvelopeReceiverService
|
private readonly IStringLocalizer<Resource> _localizer;
|
||||||
|
|
||||||
|
private readonly ISmsSender _smsSender;
|
||||||
|
|
||||||
|
public EnvelopeReceiverService(IEnvelopeReceiverRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper, ISmsSender smsSender)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
private readonly IStringLocalizer<Resource> _localizer;
|
_localizer = localizer;
|
||||||
|
_smsSender = smsSender;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly ISmsSender _smsSender;
|
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true)
|
||||||
|
{
|
||||||
|
var env_rcvs = await _repository.ReadBySignatureAsync(signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
||||||
|
return Result.Success(_mapper.Map<IEnumerable<EnvelopeReceiverDto>>(env_rcvs));
|
||||||
|
}
|
||||||
|
|
||||||
public EnvelopeReceiverService(IEnvelopeReceiverRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper, ISmsSender smsSender)
|
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true)
|
||||||
: base(repository, mapper)
|
{
|
||||||
{
|
var env_rcvs = await _repository.ReadByUuidAsync(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
||||||
_localizer = localizer;
|
return Result.Success(_mapper.Map<IEnumerable<EnvelopeReceiverDto>>(env_rcvs));
|
||||||
_smsSender = smsSender;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true)
|
public async Task<DataResult<IEnumerable<string?>>> ReadAccessCodeByUuidAsync(string uuid, bool withEnvelope = false, bool withReceiver = true)
|
||||||
{
|
{
|
||||||
var env_rcvs = await _repository.ReadBySignatureAsync(signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
var env_rcvs = await _repository.ReadByUuidAsync(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver);
|
||||||
return Result.Success(_mapper.Map<IEnumerable<EnvelopeReceiverDto>>(env_rcvs));
|
return Result.Success(env_rcvs.Select(er => er.AccessCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true)
|
public async Task<DataResult<EnvelopeReceiverDto>> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
|
||||||
{
|
{
|
||||||
var env_rcvs = await _repository.ReadByUuidAsync(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
var env_rcv = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
||||||
return Result.Success(_mapper.Map<IEnumerable<EnvelopeReceiverDto>>(env_rcvs));
|
if (env_rcv is null)
|
||||||
}
|
return Result.Fail<EnvelopeReceiverDto>()
|
||||||
|
.Message(Key.EnvelopeReceiverNotFound);
|
||||||
|
|
||||||
public async Task<DataResult<IEnumerable<string?>>> ReadAccessCodeByUuidAsync(string uuid, bool withEnvelope = false, bool withReceiver = true)
|
return Result.Success(_mapper.Map<EnvelopeReceiverDto>(env_rcv));
|
||||||
{
|
}
|
||||||
var env_rcvs = await _repository.ReadByUuidAsync(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver);
|
|
||||||
return Result.Success(env_rcvs.Select(er => er.AccessCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<DataResult<EnvelopeReceiverDto>> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
|
public async Task<DataResult<EnvelopeReceiverSecretDto>> ReadWithSecretByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
|
||||||
{
|
{
|
||||||
var env_rcv = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
var env_rcv = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
||||||
if (env_rcv is null)
|
if (env_rcv is null)
|
||||||
return Result.Fail<EnvelopeReceiverDto>()
|
return Result.Fail<EnvelopeReceiverSecretDto>()
|
||||||
.Message(Key.EnvelopeReceiverNotFound);
|
.Message(Key.EnvelopeReceiverNotFound);
|
||||||
|
|
||||||
return Result.Success(_mapper.Map<EnvelopeReceiverDto>(env_rcv));
|
return Result.Success(_mapper.Map<EnvelopeReceiverSecretDto>(env_rcv));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<EnvelopeReceiverSecretDto>> ReadWithSecretByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
|
public async Task<DataResult<EnvelopeReceiverDto>> ReadByEnvelopeReceiverIdAsync(string envelopeReceiverId, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
|
||||||
{
|
{
|
||||||
var env_rcv = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
||||||
if (env_rcv is null)
|
|
||||||
return Result.Fail<EnvelopeReceiverSecretDto>()
|
|
||||||
.Message(Key.EnvelopeReceiverNotFound);
|
|
||||||
|
|
||||||
return Result.Success(_mapper.Map<EnvelopeReceiverSecretDto>(env_rcv));
|
if (uuid is null || signature is null)
|
||||||
}
|
return Result.Fail<EnvelopeReceiverDto>()
|
||||||
|
.Message(_localizer[Key.WrongEnvelopeReceiverId])
|
||||||
|
.Notice(LogLevel.Warning, (uuid, signature).ToTitle())
|
||||||
|
.Notice(LogLevel.Warning, EnvelopeFlag.WrongEnvelopeReceiverId)
|
||||||
|
.Notice(LogLevel.Warning, Flag.PossibleSecurityBreach);
|
||||||
|
|
||||||
public async Task<DataResult<EnvelopeReceiverDto>> ReadByEnvelopeReceiverIdAsync(string envelopeReceiverId, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
|
return await ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
||||||
{
|
}
|
||||||
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
|
||||||
|
|
||||||
if (uuid is null || signature is null)
|
public async Task<DataResult<bool>> VerifyAccessCodeAsync(string uuid, string signature, string accessCode)
|
||||||
return Result.Fail<EnvelopeReceiverDto>()
|
{
|
||||||
.Message(_localizer[Key.WrongEnvelopeReceiverId])
|
var er = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature);
|
||||||
.Notice(LogLevel.Warning, (uuid, signature).ToTitle())
|
|
||||||
.Notice(LogLevel.Warning, EnvelopeFlag.WrongEnvelopeReceiverId)
|
|
||||||
.Notice(LogLevel.Warning, Flag.PossibleSecurityBreach);
|
|
||||||
|
|
||||||
return await ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly);
|
if (er is null)
|
||||||
}
|
return Result.Fail<bool>()
|
||||||
|
.Message(_localizer[Key.EnvelopeOrReceiverNonexists])
|
||||||
|
.Notice(LogLevel.Warning, (uuid, signature).ToTitle())
|
||||||
|
.Notice(LogLevel.Warning, EnvelopeFlag.EnvelopeOrReceiverNonexists)
|
||||||
|
.Notice(LogLevel.Warning, Flag.PossibleDataIntegrityIssue);
|
||||||
|
|
||||||
public async Task<DataResult<bool>> VerifyAccessCodeAsync(string uuid, string signature, string accessCode)
|
var actualAccessCode = er.AccessCode;
|
||||||
{
|
|
||||||
var er = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature);
|
|
||||||
|
|
||||||
if (er is null)
|
if (actualAccessCode is null)
|
||||||
return Result.Fail<bool>()
|
return Result.Fail<bool>()
|
||||||
.Message(_localizer[Key.EnvelopeOrReceiverNonexists])
|
.Message(_localizer[Key.AccessCodeNull])
|
||||||
.Notice(LogLevel.Warning, (uuid, signature).ToTitle())
|
.Notice(LogLevel.Critical, (uuid, signature).ToTitle())
|
||||||
.Notice(LogLevel.Warning, EnvelopeFlag.EnvelopeOrReceiverNonexists)
|
.Notice(LogLevel.Critical, EnvelopeFlag.AccessCodeNull)
|
||||||
.Notice(LogLevel.Warning, Flag.PossibleDataIntegrityIssue);
|
.Notice(LogLevel.Critical, Flag.DataIntegrityIssue);
|
||||||
|
|
||||||
var actualAccessCode = er.AccessCode;
|
else if (accessCode != actualAccessCode)
|
||||||
|
return Result.Success(false).Message(_localizer[Key.WrongAccessCode]);
|
||||||
|
else
|
||||||
|
return Result.Success(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (actualAccessCode is null)
|
public async Task<DataResult<bool>> VerifyAccessCodeAsync(string envelopeReceiverId, string accessCode)
|
||||||
return Result.Fail<bool>()
|
{
|
||||||
.Message(_localizer[Key.AccessCodeNull])
|
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
||||||
.Notice(LogLevel.Critical, (uuid, signature).ToTitle())
|
|
||||||
.Notice(LogLevel.Critical, EnvelopeFlag.AccessCodeNull)
|
|
||||||
.Notice(LogLevel.Critical, Flag.DataIntegrityIssue);
|
|
||||||
|
|
||||||
else if (accessCode != actualAccessCode)
|
if (uuid is null || signature is null)
|
||||||
return Result.Success(false).Message(_localizer[Key.WrongAccessCode]);
|
return Result.Fail<bool>()
|
||||||
else
|
.Message(Key.WrongEnvelopeReceiverId)
|
||||||
return Result.Success(true);
|
.Notice(LogLevel.Critical, EnvelopeFlag.WrongEnvelopeReceiverId)
|
||||||
}
|
.Notice(LogLevel.Critical, Flag.SecurityBreach)
|
||||||
|
.Notice(LogLevel.Critical, "Attempt to verify access code detected. Such actions are generally not initiated by well-intentioned users. Potential security breach suspected. Immediate investigation required.");
|
||||||
|
|
||||||
public async Task<DataResult<bool>> VerifyAccessCodeAsync(string envelopeReceiverId, string accessCode)
|
return await VerifyAccessCodeAsync(uuid: uuid, signature: signature, accessCode: accessCode);
|
||||||
{
|
}
|
||||||
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
|
||||||
|
|
||||||
if (uuid is null || signature is null)
|
public async Task<DataResult<bool>> IsExisting(string envelopeReceiverId)
|
||||||
return Result.Fail<bool>()
|
{
|
||||||
.Message(Key.WrongEnvelopeReceiverId)
|
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
||||||
.Notice(LogLevel.Critical, EnvelopeFlag.WrongEnvelopeReceiverId)
|
|
||||||
.Notice(LogLevel.Critical, Flag.SecurityBreach)
|
|
||||||
.Notice(LogLevel.Critical, "Attempt to verify access code detected. Such actions are generally not initiated by well-intentioned users. Potential security breach suspected. Immediate investigation required.");
|
|
||||||
|
|
||||||
return await VerifyAccessCodeAsync(uuid: uuid, signature: signature, accessCode: accessCode);
|
if (uuid is null || signature is null)
|
||||||
}
|
return Result.Fail<bool>().Notice(LogLevel.Warning, EnvelopeFlag.NonDecodableEnvelopeReceiverId, "In IsExisting(string envelopeReceiverId)");
|
||||||
|
|
||||||
public async Task<DataResult<bool>> IsExisting(string envelopeReceiverId)
|
int count = await _repository.CountAsync(uuid:uuid, signature:signature);
|
||||||
{
|
return Result.Success(count > 0);
|
||||||
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
}
|
||||||
|
|
||||||
if (uuid is null || signature is null)
|
|
||||||
return Result.Fail<bool>().Notice(LogLevel.Warning, EnvelopeFlag.NonDecodableEnvelopeReceiverId, "In IsExisting(string envelopeReceiverId)");
|
|
||||||
|
|
||||||
int count = await _repository.CountAsync(uuid:uuid, signature:signature);
|
|
||||||
return Result.Success(count > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<DataResult<string>> ReadAccessCodeByIdAsync(int envelopeId, int receiverId)
|
public async Task<DataResult<string>> ReadAccessCodeByIdAsync(int envelopeId, int receiverId)
|
||||||
{
|
{
|
||||||
var code = await _repository.ReadAccessCodeByIdAsync(envelopeId: envelopeId, receiverId: receiverId);
|
var code = await _repository.ReadAccessCodeByIdAsync(envelopeId: envelopeId, receiverId: receiverId);
|
||||||
return code is null ?
|
return code is null ?
|
||||||
Result.Fail<string>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"Access code is null. Envelope ID is {envelopeId} and receiver ID {receiverId}")
|
Result.Fail<string>().Notice(LogLevel.Error, Flag.DataIntegrityIssue, $"Access code is null. Envelope ID is {envelopeId} and receiver ID {receiverId}")
|
||||||
: Result.Success(code);
|
: Result.Success(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
public async Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
||||||
{
|
{
|
||||||
var er_list = await _repository.ReadByUsernameAsync(username: username, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses);
|
var er_list = await _repository.ReadByUsernameAsync(username: username, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses);
|
||||||
var dto_list = _mapper.Map<IEnumerable<EnvelopeReceiverDto>>(er_list);
|
var dto_list = _mapper.Map<IEnumerable<EnvelopeReceiverDto>>(er_list);
|
||||||
return Result.Success(dto_list);
|
return Result.Success(dto_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<string?>> ReadLastUsedReceiverNameByMail(string mail)
|
public async Task<DataResult<string?>> ReadLastUsedReceiverNameByMail(string mail)
|
||||||
{
|
{
|
||||||
var er = await _repository.ReadLastByReceiver(mail);
|
var er = await _repository.ReadLastByReceiver(mail);
|
||||||
return er is null ? Result.Fail<string?>().Notice(LogLevel.None, Flag.NotFound) : Result.Success(er.Name);
|
return er is null ? Result.Fail<string?>().Notice(LogLevel.None, Flag.NotFound) : Result.Success(er.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<SmsResponse>> SendSmsAsync(string envelopeReceiverId, string message)
|
public async Task<DataResult<SmsResponse>> SendSmsAsync(string envelopeReceiverId, string message)
|
||||||
{
|
{
|
||||||
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
(string? uuid, string? signature) = envelopeReceiverId.DecodeEnvelopeReceiverId();
|
||||||
|
|
||||||
if (uuid is null || signature is null)
|
if (uuid is null || signature is null)
|
||||||
return Result.Fail<SmsResponse>()
|
return Result.Fail<SmsResponse>()
|
||||||
.Message(_localizer[Key.WrongEnvelopeReceiverId])
|
.Message(_localizer[Key.WrongEnvelopeReceiverId])
|
||||||
.Notice(LogLevel.Warning, (uuid, signature).ToTitle())
|
.Notice(LogLevel.Warning, (uuid, signature).ToTitle())
|
||||||
.Notice(LogLevel.Warning, EnvelopeFlag.WrongEnvelopeReceiverId)
|
.Notice(LogLevel.Warning, EnvelopeFlag.WrongEnvelopeReceiverId)
|
||||||
.Notice(LogLevel.Warning, Flag.PossibleSecurityBreach);
|
.Notice(LogLevel.Warning, Flag.PossibleSecurityBreach);
|
||||||
|
|
||||||
var env_rcv = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: false, withReceiver: false);
|
var env_rcv = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: false, withReceiver: false);
|
||||||
if (env_rcv is null)
|
if (env_rcv is null)
|
||||||
return Result.Fail<SmsResponse>()
|
return Result.Fail<SmsResponse>()
|
||||||
.Message(Key.EnvelopeReceiverNotFound);
|
.Message(Key.EnvelopeReceiverNotFound);
|
||||||
|
|
||||||
if (env_rcv.PhoneNumber is null)
|
if (env_rcv.PhoneNumber is null)
|
||||||
return Result.Fail<SmsResponse>()
|
return Result.Fail<SmsResponse>()
|
||||||
.Message(Key.PhoneNumberNonexists)
|
.Message(Key.PhoneNumberNonexists)
|
||||||
.Notice(LogLevel.Error, Flag.NotFound, $"An attempt was made to send sms to the user whose phone number is null. Envelope recipient ID is {envelopeReceiverId}, UUID is {uuid} and signature is {signature}.");
|
.Notice(LogLevel.Error, Flag.NotFound, $"An attempt was made to send sms to the user whose phone number is null. Envelope recipient ID is {envelopeReceiverId}, UUID is {uuid} and signature is {signature}.");
|
||||||
|
|
||||||
var res = await _smsSender.SendSmsAsync(recipient: env_rcv.PhoneNumber, message: message);
|
var res = await _smsSender.SendSmsAsync(recipient: env_rcv.PhoneNumber, message: message);
|
||||||
|
|
||||||
return Result.Success(res);
|
return Result.Success(res);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,43 +1,42 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>, IEnvelopeService
|
||||||
{
|
{
|
||||||
public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>, IEnvelopeService
|
public EnvelopeService(IEnvelopeRepository repository, IMapper mapper)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
public EnvelopeService(IEnvelopeRepository repository, IMapper mapper)
|
}
|
||||||
: base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<DataResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false)
|
public async Task<DataResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false)
|
||||||
{
|
{
|
||||||
var envelopes = await _repository.ReadAllWithAsync(documents: documents, history: history, documentReceiverElement: documentReceiverElement);
|
var envelopes = await _repository.ReadAllWithAsync(documents: documents, history: history, documentReceiverElement: documentReceiverElement);
|
||||||
var readDto = _mapper.Map<IEnumerable<EnvelopeDto>>(envelopes);
|
var readDto = _mapper.Map<IEnumerable<EnvelopeDto>>(envelopes);
|
||||||
return Result.Success(readDto);
|
return Result.Success(readDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false)
|
public async Task<DataResult<EnvelopeDto>> 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);
|
var envelope = await _repository.ReadByUuidAsync(uuid: uuid, withDocuments: withDocuments, withHistory: withHistory, withDocumentReceiverElement: withDocumentReceiverElement, withUser:withUser, withAll:withAll);
|
||||||
|
|
||||||
if (envelope is null)
|
if (envelope is null)
|
||||||
return Result.Fail<EnvelopeDto>();
|
return Result.Fail<EnvelopeDto>();
|
||||||
|
|
||||||
var readDto = _mapper.Map<EnvelopeDto>(envelope);
|
var readDto = _mapper.Map<EnvelopeDto>(envelope);
|
||||||
return Result.Success(readDto);
|
return Result.Success(readDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
public async Task<DataResult<IEnumerable<EnvelopeDto>>> 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);
|
var users = await _repository.ReadByUserAsync(userId: userId, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses);
|
||||||
var readDto = _mapper.Map<IEnumerable<EnvelopeDto>>(users);
|
var readDto = _mapper.Map<IEnumerable<EnvelopeDto>>(users);
|
||||||
return Result.Success(readDto);
|
return Result.Success(readDto);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
using EnvelopeGenerator.Application.Configurations;
|
using EnvelopeGenerator.Application.Configurations;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||||
using EnvelopeGenerator.Application.Extensions;
|
using EnvelopeGenerator.Application.Extensions;
|
||||||
|
|||||||
@ -1,30 +1,29 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class EnvelopeTypeService : BasicCRUDService<IEnvelopeTypeRepository, EnvelopeTypeDto, EnvelopeType, int>, IEnvelopeTypeService
|
||||||
{
|
{
|
||||||
public class EnvelopeTypeService : BasicCRUDService<IEnvelopeTypeRepository, EnvelopeTypeDto, EnvelopeType, int>, IEnvelopeTypeService
|
private static readonly Guid CacheKey = Guid.NewGuid();
|
||||||
|
|
||||||
|
private readonly IMemoryCache _cache;
|
||||||
|
|
||||||
|
public EnvelopeTypeService(IEnvelopeTypeRepository repository, IMapper mapper, IMemoryCache cache)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
private static readonly Guid CacheKey = Guid.NewGuid();
|
_cache = cache;
|
||||||
|
|
||||||
private readonly IMemoryCache _cache;
|
|
||||||
|
|
||||||
public EnvelopeTypeService(IEnvelopeTypeRepository repository, IMapper mapper, IMemoryCache cache)
|
|
||||||
: base(repository, mapper)
|
|
||||||
{
|
|
||||||
_cache = cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task<DataResult<IEnumerable<EnvelopeTypeDto>>> ReadAllAsync()
|
|
||||||
=> await _cache.GetOrCreateAsync(CacheKey, async entry => await base.ReadAllAsync())
|
|
||||||
?? Result.Fail<IEnumerable<EnvelopeTypeDto>>().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.");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task<DataResult<IEnumerable<EnvelopeTypeDto>>> ReadAllAsync()
|
||||||
|
=> await _cache.GetOrCreateAsync(CacheKey, async entry => await base.ReadAllAsync())
|
||||||
|
?? Result.Fail<IEnumerable<EnvelopeTypeDto>>().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.");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
using DigitalData.Core.Abstractions.Client;
|
using DigitalData.Core.Abstractions.Client;
|
||||||
using DigitalData.Core.Client;
|
using DigitalData.Core.Client;
|
||||||
using EnvelopeGenerator.Application.Configurations;
|
using EnvelopeGenerator.Application.Configurations;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
|||||||
@ -1,52 +1,51 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using DigitalData.Core.Abstractions;
|
using DigitalData.Core.Abstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class ReceiverService : CRUDService<IReceiverRepository, ReceiverCreateDto, ReceiverReadDto, ReceiverUpdateDto, Receiver, int>, IReceiverService
|
||||||
{
|
{
|
||||||
public class ReceiverService : CRUDService<IReceiverRepository, ReceiverCreateDto, ReceiverReadDto, ReceiverUpdateDto, Receiver, int>, IReceiverService
|
public ReceiverService(IReceiverRepository repository, IMapper mapper)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
public ReceiverService(IReceiverRepository repository, IMapper mapper)
|
}
|
||||||
: base(repository, mapper)
|
|
||||||
|
public async Task<DataResult<ReceiverReadDto>> ReadByAsync(string? emailAddress = null, string? signature = null)
|
||||||
|
{
|
||||||
|
var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature);
|
||||||
|
|
||||||
|
if (rcv is null)
|
||||||
|
return Result.Fail<ReceiverReadDto>();
|
||||||
|
|
||||||
|
return Result.Success(_mapper.Map<ReceiverReadDto>(rcv));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null)
|
||||||
|
{
|
||||||
|
var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature);
|
||||||
|
|
||||||
|
if (rcv is null)
|
||||||
|
return Result.Fail();
|
||||||
|
|
||||||
|
return await _repository.DeleteAsync(rcv) ? Result.Success() : Result.Fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto) where TUpdateDto : IUnique<int>
|
||||||
|
{
|
||||||
|
var val = await _repository.ReadByIdAsync(updateDto.Id);
|
||||||
|
if (val == null)
|
||||||
{
|
{
|
||||||
|
return Result.Fail().Notice(LogLevel.Warning, Flag.NotFound, $"{updateDto.Id} is not found in update process of {GetType()} entity.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<DataResult<ReceiverReadDto>> ReadByAsync(string? emailAddress = null, string? signature = null)
|
var entity = _mapper.Map(updateDto, val);
|
||||||
{
|
return (await _repository.UpdateAsync(entity)) ? Result.Success() : Result.Fail();
|
||||||
var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature);
|
|
||||||
|
|
||||||
if (rcv is null)
|
|
||||||
return Result.Fail<ReceiverReadDto>();
|
|
||||||
|
|
||||||
return Result.Success(_mapper.Map<ReceiverReadDto>(rcv));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null)
|
|
||||||
{
|
|
||||||
var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature);
|
|
||||||
|
|
||||||
if (rcv is null)
|
|
||||||
return Result.Fail();
|
|
||||||
|
|
||||||
return await _repository.DeleteAsync(rcv) ? Result.Success() : Result.Fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual async Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto) where TUpdateDto : IUnique<int>
|
|
||||||
{
|
|
||||||
var val = await _repository.ReadByIdAsync(updateDto.Id);
|
|
||||||
if (val == null)
|
|
||||||
{
|
|
||||||
return Result.Fail().Notice(LogLevel.Warning, Flag.NotFound, $"{updateDto.Id} is not found in update process of {GetType()} entity.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var entity = _mapper.Map(updateDto, val);
|
|
||||||
return (await _repository.UpdateAsync(entity)) ? Result.Success() : Result.Fail();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,17 +1,16 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using DigitalData.Core.Application;
|
using DigitalData.Core.Application;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs;
|
using EnvelopeGenerator.Application.DTOs;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services;
|
||||||
|
|
||||||
|
public class UserReceiverService : BasicCRUDService<IUserReceiverRepository, UserReceiverDto, UserReceiver, int>, IUserReceiverService
|
||||||
{
|
{
|
||||||
public class UserReceiverService : BasicCRUDService<IUserReceiverRepository, UserReceiverDto, UserReceiver, int>, IUserReceiverService
|
public UserReceiverService(IUserReceiverRepository repository, IMapper mapper)
|
||||||
|
: base(repository, mapper)
|
||||||
{
|
{
|
||||||
public UserReceiverService(IUserReceiverRepository repository, IMapper mapper)
|
|
||||||
: base(repository, mapper)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,6 +50,6 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
public (int Envelope, int Receiver) Id => (Envelope: EnvelopeId, Receiver: ReceiverId);
|
public (int Envelope, int Receiver) Id => (Envelope: EnvelopeId, Receiver: ReceiverId);
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool HasPhoneNumber => PhoneNumber is not null;
|
public bool HasPhoneNumber => !string.IsNullOrWhiteSpace(PhoneNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Common.My.Resources;
|
using EnvelopeGenerator.Common.My.Resources;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
using EnvelopeGenerator.Application.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Services;
|
||||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IConfigRepository : ICRUDRepository<Config, int>
|
|
||||||
{
|
|
||||||
Task<Config?> ReadFirstAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IDocumentReceiverElementRepository : ICRUDRepository<DocumentReceiverElement, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IDocumentStatusRepository : ICRUDRepository<DocumentStatus, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
using static EnvelopeGenerator.Common.Constants;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IEmailTemplateRepository : ICRUDRepository<EmailTemplate, int>
|
|
||||||
{
|
|
||||||
Task<EmailTemplate?> ReadByNameAsync(EmailTemplateType type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeCertificateRepository : ICRUDRepository<EnvelopeCertificate, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeDocumentRepository : ICRUDRepository<EnvelopeDocument, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, long>
|
|
||||||
{
|
|
||||||
Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null);
|
|
||||||
|
|
||||||
Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeReceiverReadOnlyRepository : ICRUDRepository<EnvelopeReceiverReadOnly, long>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeReceiverRepository : ICRUDRepository<EnvelopeReceiver, (int Envelope, int Receiver)>
|
|
||||||
{
|
|
||||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<IEnumerable<EnvelopeReceiver>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<EnvelopeReceiver?> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<string?> ReadAccessCodeAsync(string uuid, string signature, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<int> CountAsync(string uuid, string signature);
|
|
||||||
|
|
||||||
Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = true);
|
|
||||||
|
|
||||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
|
||||||
|
|
||||||
Task<EnvelopeReceiver?> ReadLastByReceiver(string email);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeRepository : ICRUDRepository<Envelope, int>
|
|
||||||
{
|
|
||||||
Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false);
|
|
||||||
|
|
||||||
Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false);
|
|
||||||
|
|
||||||
Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IEnvelopeTypeRepository : ICRUDRepository<EnvelopeType, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IReceiverRepository : ICRUDRepository<Receiver, int>
|
|
||||||
{
|
|
||||||
Task<Receiver?> ReadByAsync(string? emailAddress = null, string? signature = null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Contracts
|
|
||||||
{
|
|
||||||
public interface IUserReceiverRepository : ICRUDRepository<UserReceiver, int>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
37
EnvelopeGenerator.Infrastructure/DIExtensions.cs
Normal file
37
EnvelopeGenerator.Infrastructure/DIExtensions.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
using EnvelopeGenerator.Application.Extensions;
|
||||||
|
using EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure;
|
||||||
|
|
||||||
|
public static class DIExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddEnvelopeGeneratorRepositories(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.TryAddScoped<IConfigRepository, ConfigRepository>();
|
||||||
|
services.TryAddScoped<IDocumentReceiverElementRepository, DocumentReceiverElementRepository>();
|
||||||
|
services.TryAddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
|
||||||
|
services.TryAddScoped<IConfigRepository, ConfigRepository>();
|
||||||
|
services.TryAddScoped<IDocumentReceiverElementRepository, DocumentReceiverElementRepository>();
|
||||||
|
services.TryAddScoped<IDocumentStatusRepository, DocumentStatusRepository>();
|
||||||
|
services.TryAddScoped<IEmailTemplateRepository, EmailTemplateRepository>();
|
||||||
|
services.TryAddScoped<IEnvelopeRepository, EnvelopeRepository>();
|
||||||
|
services.TryAddScoped<IEnvelopeCertificateRepository, EnvelopeCertificateRepository>();
|
||||||
|
services.TryAddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
|
||||||
|
services.TryAddScoped<IEnvelopeHistoryRepository, EnvelopeHistoryRepository>();
|
||||||
|
services.TryAddScoped<IEnvelopeReceiverRepository, EnvelopeReceiverRepository>();
|
||||||
|
services.TryAddScoped<IEnvelopeTypeRepository, EnvelopeTypeRepository>();
|
||||||
|
services.TryAddScoped<IReceiverRepository, ReceiverRepository>();
|
||||||
|
services.TryAddScoped<IUserReceiverRepository, UserReceiverRepository>();
|
||||||
|
services.TryAddScoped<IEnvelopeReceiverReadOnlyRepository, EnvelopeReceiverReadOnlyRepository>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddEnvelopeGenerator(this IServiceCollection services, IConfiguration configuration) => services
|
||||||
|
.AddEnvelopeGeneratorRepositories()
|
||||||
|
.AddEnvelopeGeneratorServices(configuration);
|
||||||
|
}
|
||||||
@ -7,145 +7,174 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Group = DigitalData.UserManager.Domain.Entities.Group;
|
using Group = DigitalData.UserManager.Domain.Entities.Group;
|
||||||
using Module = DigitalData.UserManager.Domain.Entities.Module;
|
using Module = DigitalData.UserManager.Domain.Entities.Module;
|
||||||
using DigitalData.EmailProfilerDispatcher;
|
using DigitalData.EmailProfilerDispatcher;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using EnvelopeGenerator.Application.Configurations;
|
||||||
|
using DigitalData.Core.Client;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure
|
namespace EnvelopeGenerator.Infrastructure;
|
||||||
|
|
||||||
|
//TODO: Adding EmailOut instead of EmailOut.Abst is not correct for the arch. Re-design EmailPut consedering this. IMailDbContext shoud move to Abstraction layer (hint: in this case using DBSet in abst. will be problem because entity framework will have to be added.
|
||||||
|
public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
|
||||||
{
|
{
|
||||||
//TODO: Adding EmailOut instead of EmailOut.Abst is not correct for the arch. Re-design EmailPut consedering this. IMailDbContext shoud move to Abstraction layer (hint: in this case using DBSet in abst. will be problem because entity framework will have to be added.
|
public DbSet<UserReceiver> UserReceivers { get; set; }
|
||||||
public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
|
|
||||||
|
public DbSet<Config> Configs { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EnvelopeReceiver> EnvelopeReceivers { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Envelope> Envelopes { get; set; }
|
||||||
|
|
||||||
|
public DbSet<DocumentReceiverElement> DocumentReceiverElements { get; set; }
|
||||||
|
|
||||||
|
public DbSet<DocumentStatus> DocumentStatus { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EmailTemplate> EmailTemplate { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EnvelopeCertificate> EnvelopeCertificates { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EnvelopeDocument> EnvelopeDocument { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EnvelopeHistory> EnvelopeHistories { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EnvelopeType> EnvelopeTypes { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Receiver> Receivers { get; set; }
|
||||||
|
|
||||||
|
public DbSet<GroupOfUser> GroupOfUsers { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Group> Groups { get; set; }
|
||||||
|
|
||||||
|
public DbSet<ModuleOfUser> ModuleOfUsers { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Module> Modules { get; set; }
|
||||||
|
|
||||||
|
public DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
|
public DbSet<UserRep> UserReps { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EmailOut> EMailOuts { get; set; }
|
||||||
|
|
||||||
|
public DbSet<EnvelopeReceiverReadOnly> EnvelopeReceiverReadOnlys { get; set; }
|
||||||
|
|
||||||
|
private readonly DbTriggerParams _triggers;
|
||||||
|
|
||||||
|
private readonly ILogger<EGDbContext> _logger;
|
||||||
|
|
||||||
|
public EGDbContext(DbContextOptions<EGDbContext> options, IOptions<DbTriggerParams> triggerParamOptions, ILogger<EGDbContext> logger) : base(options)
|
||||||
{
|
{
|
||||||
public DbSet<UserReceiver> UserReceivers { get; set; }
|
_triggers = triggerParamOptions.Value;
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
public DbSet<Config> Configs { get; set; }
|
UserReceivers = Set<UserReceiver>();
|
||||||
|
Configs = Set<Config>();
|
||||||
|
EnvelopeReceivers = Set<EnvelopeReceiver>();
|
||||||
|
Envelopes = Set<Envelope>();
|
||||||
|
DocumentReceiverElements = Set<DocumentReceiverElement>();
|
||||||
|
DocumentStatus = Set<DocumentStatus>();
|
||||||
|
EnvelopeCertificates = Set<EnvelopeCertificate>();
|
||||||
|
EnvelopeDocument = Set<EnvelopeDocument>();
|
||||||
|
EnvelopeHistories = Set<EnvelopeHistory>();
|
||||||
|
EnvelopeTypes = Set<EnvelopeType>();
|
||||||
|
Receivers = Set<Receiver>();
|
||||||
|
|
||||||
public DbSet<EnvelopeReceiver> EnvelopeReceivers { get; set; }
|
GroupOfUsers = Set<GroupOfUser>();
|
||||||
|
Groups = Set<Group>();
|
||||||
|
ModuleOfUsers = Set<ModuleOfUser>();
|
||||||
|
Modules = Set<Module>();
|
||||||
|
Users = Set<User>();
|
||||||
|
UserReps = Set<UserRep>();
|
||||||
|
EMailOuts = Set<EmailOut>();
|
||||||
|
EnvelopeReceiverReadOnlys = Set<EnvelopeReceiverReadOnly>();
|
||||||
|
}
|
||||||
|
|
||||||
public DbSet<Envelope> Envelopes { get; set; }
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<Config>().HasNoKey();
|
||||||
|
|
||||||
public DbSet<DocumentReceiverElement> DocumentReceiverElements { get; set; }
|
modelBuilder.Entity<EnvelopeReceiver>()
|
||||||
|
.HasKey(er => new { er.EnvelopeId, er.ReceiverId });
|
||||||
|
|
||||||
public DbSet<DocumentStatus> DocumentStatus { get; set; }
|
modelBuilder.Entity<EnvelopeDocument>();
|
||||||
|
modelBuilder.Entity<DocumentReceiverElement>();
|
||||||
|
modelBuilder.Entity<DocumentStatus>();
|
||||||
|
modelBuilder.Entity<EmailTemplate>();
|
||||||
|
modelBuilder.Entity<Envelope>();
|
||||||
|
modelBuilder.Entity<EnvelopeCertificate>();
|
||||||
|
modelBuilder.Entity<EnvelopeHistory>();
|
||||||
|
modelBuilder.Entity<EnvelopeType>();
|
||||||
|
modelBuilder.Entity<Receiver>();
|
||||||
|
modelBuilder.Entity<UserReceiver>();
|
||||||
|
modelBuilder.Entity<EmailOut>();
|
||||||
|
|
||||||
public DbSet<EmailTemplate> EmailTemplate { get; set; }
|
// Configure the one-to-many relationship of Envelope
|
||||||
|
modelBuilder.Entity<Envelope>()
|
||||||
|
.HasMany(e => e.Documents)
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey(ed => ed.EnvelopeId);
|
||||||
|
|
||||||
public DbSet<EnvelopeCertificate> EnvelopeCertificates { get; set; }
|
modelBuilder.Entity<Envelope>()
|
||||||
|
.HasMany(e => e.History)
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey(eh => eh.EnvelopeId);
|
||||||
|
|
||||||
public DbSet<EnvelopeDocument> EnvelopeDocument { get; set; }
|
modelBuilder.Entity<EnvelopeDocument>()
|
||||||
|
.HasMany(ed => ed.Elements)
|
||||||
|
.WithOne(e => e.Document)
|
||||||
|
.HasForeignKey(e => e.DocumentId);
|
||||||
|
|
||||||
public DbSet<EnvelopeHistory> EnvelopeHistories { get; set; }
|
modelBuilder.Entity<DocumentReceiverElement>()
|
||||||
|
.HasOne(dre => dre.Document)
|
||||||
|
.WithMany(ed => ed.Elements)
|
||||||
|
.HasForeignKey(dre => dre.DocumentId);
|
||||||
|
|
||||||
public DbSet<EnvelopeType> EnvelopeTypes { get; set; }
|
modelBuilder.Entity<EnvelopeHistory>()
|
||||||
|
.HasOne(eh => eh.Receiver)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(eh => eh.UserReference)
|
||||||
|
.HasPrincipalKey(e => e.EmailAddress);
|
||||||
|
|
||||||
public DbSet<Receiver> Receivers { get; set; }
|
modelBuilder.Entity<EnvelopeHistory>()
|
||||||
|
.HasOne(eh => eh.Sender)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(eh => eh.UserReference)
|
||||||
|
.HasPrincipalKey(e => e.Email);
|
||||||
|
|
||||||
public DbSet<GroupOfUser> GroupOfUsers { get; set; }
|
modelBuilder.Entity<EnvelopeReceiverReadOnly>()
|
||||||
|
.HasOne(erro => erro.Receiver)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(erro => erro.AddedWho)
|
||||||
|
.HasPrincipalKey(r => r.EmailAddress);
|
||||||
|
|
||||||
public DbSet<Group> Groups { get; set; }
|
// Configure entities to handle database triggers
|
||||||
|
void AddTrigger<T>() where T : class => _triggers
|
||||||
|
.Where(t => t.Key == typeof(T).Name)
|
||||||
|
.SelectMany(t => t.Value)
|
||||||
|
.ForEach(tName =>
|
||||||
|
{
|
||||||
|
modelBuilder.Entity<T>().ToTable(tb => tb.HasTrigger(tName));
|
||||||
|
_logger.LogInformation("Trigger '{triggerName}' has been added to the '{entityName}' entity.", tName, typeof(T).Name);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: call add trigger methods with attributes and reflection
|
||||||
|
AddTrigger<Config>();
|
||||||
|
AddTrigger<DocumentReceiverElement>();
|
||||||
|
AddTrigger<DocumentStatus>();
|
||||||
|
AddTrigger<EmailTemplate>();
|
||||||
|
AddTrigger<Envelope>();
|
||||||
|
AddTrigger<EnvelopeCertificate>();
|
||||||
|
AddTrigger<EnvelopeDocument>();
|
||||||
|
AddTrigger<EnvelopeHistory>();
|
||||||
|
AddTrigger<EnvelopeReceiver>();
|
||||||
|
AddTrigger<EnvelopeReceiverReadOnly>();
|
||||||
|
AddTrigger<EnvelopeType>();
|
||||||
|
AddTrigger<Receiver>();
|
||||||
|
AddTrigger<UserReceiver>();
|
||||||
|
AddTrigger<EmailOut>();
|
||||||
|
|
||||||
public DbSet<ModuleOfUser> ModuleOfUsers { get; set; }
|
//configure model builder for user manager tables
|
||||||
|
modelBuilder.ConfigureUserManager();
|
||||||
|
|
||||||
public DbSet<Module> Modules { get; set; }
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
public DbSet<User> Users { get; set; }
|
|
||||||
|
|
||||||
public DbSet<UserRep> UserReps { get; set; }
|
|
||||||
|
|
||||||
public DbSet<EmailOut> EMailOuts { get; set; }
|
|
||||||
|
|
||||||
public DbSet<EnvelopeReceiverReadOnly> EnvelopeReceiverReadOnlys { get; set; }
|
|
||||||
|
|
||||||
public EGDbContext(DbContextOptions<EGDbContext> options) : base(options)
|
|
||||||
{
|
|
||||||
UserReceivers = Set<UserReceiver>();
|
|
||||||
Configs = Set<Config>();
|
|
||||||
EnvelopeReceivers = Set<EnvelopeReceiver>();
|
|
||||||
Envelopes = Set<Envelope>();
|
|
||||||
DocumentReceiverElements = Set<DocumentReceiverElement>();
|
|
||||||
DocumentStatus = Set<DocumentStatus>();
|
|
||||||
EnvelopeCertificates = Set<EnvelopeCertificate>();
|
|
||||||
EnvelopeDocument = Set<EnvelopeDocument>();
|
|
||||||
EnvelopeHistories = Set<EnvelopeHistory>();
|
|
||||||
EnvelopeTypes = Set<EnvelopeType>();
|
|
||||||
Receivers = Set<Receiver>();
|
|
||||||
|
|
||||||
GroupOfUsers = Set<GroupOfUser>();
|
|
||||||
Groups = Set<Group>();
|
|
||||||
ModuleOfUsers = Set<ModuleOfUser>();
|
|
||||||
Modules = Set<Module>();
|
|
||||||
Users = Set<User>();
|
|
||||||
UserReps = Set<UserRep>();
|
|
||||||
EMailOuts = Set<EmailOut>();
|
|
||||||
EnvelopeReceiverReadOnlys = Set<EnvelopeReceiverReadOnly>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
modelBuilder.Entity<Config>().HasNoKey();
|
|
||||||
|
|
||||||
modelBuilder.Entity<EnvelopeReceiver>()
|
|
||||||
.HasKey(er => new { er.EnvelopeId, er.ReceiverId });
|
|
||||||
|
|
||||||
modelBuilder.Entity<EnvelopeDocument>();
|
|
||||||
modelBuilder.Entity<DocumentReceiverElement>();
|
|
||||||
modelBuilder.Entity<DocumentStatus>();
|
|
||||||
modelBuilder.Entity<EmailTemplate>();
|
|
||||||
modelBuilder.Entity<Envelope>();
|
|
||||||
modelBuilder.Entity<EnvelopeCertificate>();
|
|
||||||
modelBuilder.Entity<EnvelopeHistory>();
|
|
||||||
modelBuilder.Entity<EnvelopeType>();
|
|
||||||
modelBuilder.Entity<Receiver>();
|
|
||||||
modelBuilder.Entity<UserReceiver>();
|
|
||||||
modelBuilder.Entity<EmailOut>();
|
|
||||||
|
|
||||||
// Configure the one-to-many relationship of Envelope
|
|
||||||
modelBuilder.Entity<Envelope>()
|
|
||||||
.HasMany(e => e.Documents)
|
|
||||||
.WithOne()
|
|
||||||
.HasForeignKey(ed => ed.EnvelopeId);
|
|
||||||
|
|
||||||
modelBuilder.Entity<Envelope>()
|
|
||||||
.HasMany(e => e.History)
|
|
||||||
.WithOne()
|
|
||||||
.HasForeignKey(eh => eh.EnvelopeId);
|
|
||||||
|
|
||||||
modelBuilder.Entity<EnvelopeDocument>()
|
|
||||||
.HasMany(ed => ed.Elements)
|
|
||||||
.WithOne(e => e.Document)
|
|
||||||
.HasForeignKey(e => e.DocumentId);
|
|
||||||
|
|
||||||
modelBuilder.Entity<DocumentReceiverElement>()
|
|
||||||
.HasOne(dre => dre.Document)
|
|
||||||
.WithMany(ed => ed.Elements)
|
|
||||||
.HasForeignKey(dre => dre.DocumentId);
|
|
||||||
|
|
||||||
modelBuilder.Entity<EnvelopeHistory>()
|
|
||||||
.HasOne(eh => eh.Receiver)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(eh => eh.UserReference)
|
|
||||||
.HasPrincipalKey(e => e.EmailAddress);
|
|
||||||
|
|
||||||
modelBuilder.Entity<EnvelopeHistory>()
|
|
||||||
.HasOne(eh => eh.Sender)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(eh => eh.UserReference)
|
|
||||||
.HasPrincipalKey(e => e.Email);
|
|
||||||
|
|
||||||
modelBuilder.Entity<EnvelopeReceiverReadOnly>()
|
|
||||||
.HasOne(erro => erro.Receiver)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(erro => erro.AddedWho)
|
|
||||||
.HasPrincipalKey(r => r.EmailAddress);
|
|
||||||
|
|
||||||
// Configure entities to handle database triggers
|
|
||||||
modelBuilder.Entity<Envelope>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_HISTORY_AFT_INS"));
|
|
||||||
modelBuilder.Entity<EnvelopeHistory>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_HISTORY_AFT_INS"));
|
|
||||||
modelBuilder.Entity<EmailOut>().ToTable(tb => tb.HasTrigger("TBEMLP_EMAIL_OUT_AFT_INS"));
|
|
||||||
modelBuilder.Entity<EmailOut>().ToTable(tb => tb.HasTrigger("TBEMLP_EMAIL_OUT_AFT_UPD"));
|
|
||||||
modelBuilder.Entity<EnvelopeReceiverReadOnly>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD"));
|
|
||||||
|
|
||||||
//configure model builder for user manager tables
|
|
||||||
modelBuilder.ConfigureUserManager();
|
|
||||||
|
|
||||||
base.OnModelCreating(modelBuilder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,6 +20,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
|
||||||
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj" />
|
<ProjectReference Include="..\EnvelopeGenerator.Domain\EnvelopeGenerator.Domain.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
{
|
|
||||||
public class ConfigRepository : CRUDRepository<Config, int, EGDbContext>, IConfigRepository
|
|
||||||
{
|
|
||||||
public ConfigRepository(EGDbContext dbContext) : base(dbContext, dbContext.Configs)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Config?> ReadFirstAsync()
|
public class ConfigRepository : CRUDRepository<Config, int, EGDbContext>, IConfigRepository
|
||||||
{
|
{
|
||||||
var configs = await _dbSet.ToListAsync();
|
public ConfigRepository(EGDbContext dbContext) : base(dbContext, dbContext.Configs)
|
||||||
return configs.Count > 0 ? configs[0] : default;
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Config?> ReadFirstAsync()
|
||||||
|
{
|
||||||
|
var configs = await _dbSet.ToListAsync();
|
||||||
|
return configs.Count > 0 ? configs[0] : default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,13 +1,12 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class DocumentReceiverElementRepository : CRUDRepository<DocumentReceiverElement, int, EGDbContext>, IDocumentReceiverElementRepository
|
||||||
{
|
{
|
||||||
public class DocumentReceiverElementRepository : CRUDRepository<DocumentReceiverElement, int, EGDbContext>, IDocumentReceiverElementRepository
|
public DocumentReceiverElementRepository(EGDbContext dbContext) : base(dbContext, dbContext.DocumentReceiverElements)
|
||||||
{
|
{
|
||||||
public DocumentReceiverElementRepository(EGDbContext dbContext) : base(dbContext, dbContext.DocumentReceiverElements)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,14 +1,13 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using DigitalData.UserManager.Infrastructure.Repositories;
|
using DigitalData.UserManager.Infrastructure.Repositories;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class DocumentStatusRepository : CRUDRepository<DocumentStatus, int, EGDbContext>, IDocumentStatusRepository
|
||||||
{
|
{
|
||||||
public class DocumentStatusRepository : CRUDRepository<DocumentStatus, int, EGDbContext>, IDocumentStatusRepository
|
public DocumentStatusRepository(EGDbContext dbContext) : base(dbContext, dbContext.DocumentStatus)
|
||||||
{
|
{
|
||||||
public DocumentStatusRepository(EGDbContext dbContext) : base(dbContext, dbContext.DocumentStatus)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,34 +1,33 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using static EnvelopeGenerator.Common.Constants;
|
using static EnvelopeGenerator.Common.Constants;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
{
|
|
||||||
public class EmailTemplateRepository : CRUDRepository<EmailTemplate, int, EGDbContext>, IEmailTemplateRepository
|
public class EmailTemplateRepository : CRUDRepository<EmailTemplate, int, EGDbContext>, IEmailTemplateRepository
|
||||||
{
|
{
|
||||||
private readonly IMemoryCache _cache;
|
private readonly IMemoryCache _cache;
|
||||||
|
|
||||||
public EmailTemplateRepository(EGDbContext dbContext, IMemoryCache cache) : base(dbContext, dbContext.EmailTemplate)
|
public EmailTemplateRepository(EGDbContext dbContext, IMemoryCache cache) : base(dbContext, dbContext.EmailTemplate)
|
||||||
{
|
{
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Guid key_guid = Guid.NewGuid();
|
private readonly Guid key_guid = Guid.NewGuid();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves an email template based on its name.
|
/// Retrieves an email template based on its name.
|
||||||
/// Utilizes in-memory caching to improve performance for the limited number of email templates available.
|
/// Utilizes in-memory caching to improve performance for the limited number of email templates available.
|
||||||
/// If the template is not found in the cache, it queries the database and stores the result in the cache.
|
/// If the template is not found in the cache, it queries the database and stores the result in the cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">The type of the email template, which corresponds to its name.</param>
|
/// <param name="type">The type of the email template, which corresponds to its name.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A task that represents the asynchronous operation. The task result contains the email template
|
/// A task that represents the asynchronous operation. The task result contains the email template
|
||||||
/// if found, otherwise null.
|
/// if found, otherwise null.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<EmailTemplate?> ReadByNameAsync(EmailTemplateType type) => await _cache.GetOrCreateAsync($"{type}{key_guid}", async _
|
public async Task<EmailTemplate?> ReadByNameAsync(EmailTemplateType type) => await _cache.GetOrCreateAsync($"{type}{key_guid}", async _
|
||||||
=> await _dbSet.Where(t => t.Name == type.ToString()).FirstOrDefaultAsync());
|
=> await _dbSet.Where(t => t.Name == type.ToString()).FirstOrDefaultAsync());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@ -1,13 +1,12 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class EnvelopeCertificateRepository : CRUDRepository<EnvelopeCertificate, int, EGDbContext>, IEnvelopeCertificateRepository
|
||||||
{
|
{
|
||||||
public class EnvelopeCertificateRepository : CRUDRepository<EnvelopeCertificate, int, EGDbContext>, IEnvelopeCertificateRepository
|
public EnvelopeCertificateRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeCertificates)
|
||||||
{
|
{
|
||||||
public EnvelopeCertificateRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeCertificates)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,14 +1,13 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using DigitalData.UserManager.Infrastructure.Repositories;
|
using DigitalData.UserManager.Infrastructure.Repositories;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class EnvelopeDocumentRepository : CRUDRepository<EnvelopeDocument, int, EGDbContext>, IEnvelopeDocumentRepository
|
||||||
{
|
{
|
||||||
public class EnvelopeDocumentRepository : CRUDRepository<EnvelopeDocument, int, EGDbContext>, IEnvelopeDocumentRepository
|
public EnvelopeDocumentRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeDocument)
|
||||||
{
|
{
|
||||||
public EnvelopeDocumentRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeDocument)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,49 +1,48 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, EGDbContext>, IEnvelopeHistoryRepository
|
||||||
{
|
{
|
||||||
public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, EGDbContext>, IEnvelopeHistoryRepository
|
public EnvelopeHistoryRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeHistories)
|
||||||
{
|
{
|
||||||
public EnvelopeHistoryRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeHistories)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private IQueryable<EnvelopeHistory> By(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
|
||||||
{
|
|
||||||
var query = _dbSet.AsQueryable();
|
|
||||||
|
|
||||||
if (envelopeId is not null)
|
|
||||||
query = query.Where(eh => eh.EnvelopeId == envelopeId);
|
|
||||||
|
|
||||||
if (userReference is not null)
|
|
||||||
query = query.Where(eh => eh.UserReference == userReference);
|
|
||||||
|
|
||||||
if (status is not null)
|
|
||||||
query = query.Where(eh => eh.Status == status);
|
|
||||||
|
|
||||||
if (withSender)
|
|
||||||
query = query.Include(eh => eh.Sender);
|
|
||||||
|
|
||||||
if (withReceiver)
|
|
||||||
query = query.Include(eh => eh.Receiver);
|
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await By(
|
|
||||||
envelopeId: envelopeId,
|
|
||||||
userReference: userReference,
|
|
||||||
status: status).CountAsync();
|
|
||||||
|
|
||||||
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
|
||||||
=> await By(
|
|
||||||
envelopeId: envelopeId,
|
|
||||||
userReference: userReference,
|
|
||||||
status: status,
|
|
||||||
withSender: withSender,
|
|
||||||
withReceiver: withReceiver).ToListAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IQueryable<EnvelopeHistory> By(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
||||||
|
{
|
||||||
|
var query = _dbSet.AsQueryable();
|
||||||
|
|
||||||
|
if (envelopeId is not null)
|
||||||
|
query = query.Where(eh => eh.EnvelopeId == envelopeId);
|
||||||
|
|
||||||
|
if (userReference is not null)
|
||||||
|
query = query.Where(eh => eh.UserReference == userReference);
|
||||||
|
|
||||||
|
if (status is not null)
|
||||||
|
query = query.Where(eh => eh.Status == status);
|
||||||
|
|
||||||
|
if (withSender)
|
||||||
|
query = query.Include(eh => eh.Sender);
|
||||||
|
|
||||||
|
if (withReceiver)
|
||||||
|
query = query.Include(eh => eh.Receiver);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CountAsync(int? envelopeId = null, string? userReference = null, int? status = null) => await By(
|
||||||
|
envelopeId: envelopeId,
|
||||||
|
userReference: userReference,
|
||||||
|
status: status).CountAsync();
|
||||||
|
|
||||||
|
public async Task<IEnumerable<EnvelopeHistory>> ReadAsync(int? envelopeId = null, string? userReference = null, int? status = null, bool withSender = false, bool withReceiver = false)
|
||||||
|
=> await By(
|
||||||
|
envelopeId: envelopeId,
|
||||||
|
userReference: userReference,
|
||||||
|
status: status,
|
||||||
|
withSender: withSender,
|
||||||
|
withReceiver: withReceiver).ToListAsync();
|
||||||
}
|
}
|
||||||
@ -1,70 +1,69 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class EnvelopeReceiverReadOnlyRepository : CRUDRepository<EnvelopeReceiverReadOnly, long, EGDbContext>, IEnvelopeReceiverReadOnlyRepository
|
||||||
{
|
{
|
||||||
public class EnvelopeReceiverReadOnlyRepository : CRUDRepository<EnvelopeReceiverReadOnly, long, EGDbContext>, IEnvelopeReceiverReadOnlyRepository
|
private readonly IEnvelopeRepository _envRepo;
|
||||||
|
|
||||||
|
public EnvelopeReceiverReadOnlyRepository(EGDbContext dbContext, IEnvelopeRepository envelopeRepository) : base(dbContext, dbContext.EnvelopeReceiverReadOnlys)
|
||||||
{
|
{
|
||||||
private readonly IEnvelopeRepository _envRepo;
|
_envRepo = envelopeRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public EnvelopeReceiverReadOnlyRepository(EGDbContext dbContext, IEnvelopeRepository envelopeRepository) : base(dbContext, dbContext.EnvelopeReceiverReadOnlys)
|
protected override IQueryable<EnvelopeReceiverReadOnly> ReadOnly()
|
||||||
{
|
{
|
||||||
_envRepo = envelopeRepository;
|
return base.ReadOnly()
|
||||||
}
|
//TODO: add again when EnvelopeId data type is standardized
|
||||||
|
//.Include(erro => erro.Envelope)
|
||||||
|
.Include(erro => erro.Receiver);
|
||||||
|
}
|
||||||
|
|
||||||
protected override IQueryable<EnvelopeReceiverReadOnly> ReadOnly()
|
public async override Task<IEnumerable<EnvelopeReceiverReadOnly>> ReadAllAsync()
|
||||||
{
|
{
|
||||||
return base.ReadOnly()
|
var erros = await base.ReadAllAsync();
|
||||||
//TODO: add again when EnvelopeId data type is standardized
|
return await IncludeEnvelope(erros);
|
||||||
//.Include(erro => erro.Envelope)
|
}
|
||||||
.Include(erro => erro.Receiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async override Task<IEnumerable<EnvelopeReceiverReadOnly>> ReadAllAsync()
|
public override async Task<EnvelopeReceiverReadOnly?> ReadByIdAsync(long id)
|
||||||
{
|
{
|
||||||
var erros = await base.ReadAllAsync();
|
var erro = await _dbSet.AsNoTracking()
|
||||||
return await IncludeEnvelope(erros);
|
.Include(erro => erro.Receiver)
|
||||||
}
|
.Where(erro => erro.Id == id)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
public override async Task<EnvelopeReceiverReadOnly?> ReadByIdAsync(long id)
|
return await IncludeEnvelope(erro);
|
||||||
{
|
}
|
||||||
var erro = await _dbSet.AsNoTracking()
|
|
||||||
.Include(erro => erro.Receiver)
|
|
||||||
.Where(erro => erro.Id == id)
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
return await IncludeEnvelope(erro);
|
//TODO: Use IQueryable.Include instead of this when ID type is clarified.
|
||||||
}
|
[Obsolete("Use IQueryable.Include instead of this when ID type is clarified.")]
|
||||||
|
private async Task<EnvelopeReceiverReadOnly> IncludeEnvelope(EnvelopeReceiverReadOnly erro)
|
||||||
|
{
|
||||||
|
erro.Envelope = await _envRepo.ReadByIdAsync((int)erro.EnvelopeId);
|
||||||
|
return erro;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Use IQueryable.Include instead of this when ID type is clarified.
|
//TODO: Use IQueryable.Include instead of this when ID type is clarified.
|
||||||
[Obsolete("Use IQueryable.Include instead of this when ID type is clarified.")]
|
[Obsolete("Use IQueryable.Include instead of this when ID type is clarified.")]
|
||||||
private async Task<EnvelopeReceiverReadOnly> IncludeEnvelope(EnvelopeReceiverReadOnly erro)
|
private async Task<IEnumerable<EnvelopeReceiverReadOnly>> IncludeEnvelope(params EnvelopeReceiverReadOnly[] erros)
|
||||||
{
|
{
|
||||||
|
foreach (var erro in erros)
|
||||||
|
erro.Envelope = await _envRepo.ReadByIdAsync((int) erro.EnvelopeId);
|
||||||
|
|
||||||
|
return erros;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Use IQueryable.Include instead of this when ID type is clarified.
|
||||||
|
[Obsolete("Use IQueryable.Include instead of this when ID type is clarified.")]
|
||||||
|
private async Task<T> IncludeEnvelope<T>(T erros)
|
||||||
|
where T : IEnumerable<EnvelopeReceiverReadOnly>
|
||||||
|
{
|
||||||
|
foreach (var erro in erros)
|
||||||
erro.Envelope = await _envRepo.ReadByIdAsync((int)erro.EnvelopeId);
|
erro.Envelope = await _envRepo.ReadByIdAsync((int)erro.EnvelopeId);
|
||||||
return erro;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Use IQueryable.Include instead of this when ID type is clarified.
|
return erros;
|
||||||
[Obsolete("Use IQueryable.Include instead of this when ID type is clarified.")]
|
|
||||||
private async Task<IEnumerable<EnvelopeReceiverReadOnly>> IncludeEnvelope(params EnvelopeReceiverReadOnly[] erros)
|
|
||||||
{
|
|
||||||
foreach (var erro in erros)
|
|
||||||
erro.Envelope = await _envRepo.ReadByIdAsync((int) erro.EnvelopeId);
|
|
||||||
|
|
||||||
return erros;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Use IQueryable.Include instead of this when ID type is clarified.
|
|
||||||
[Obsolete("Use IQueryable.Include instead of this when ID type is clarified.")]
|
|
||||||
private async Task<T> IncludeEnvelope<T>(T erros)
|
|
||||||
where T : IEnumerable<EnvelopeReceiverReadOnly>
|
|
||||||
{
|
|
||||||
foreach (var erro in erros)
|
|
||||||
erro.Envelope = await _envRepo.ReadByIdAsync((int)erro.EnvelopeId);
|
|
||||||
|
|
||||||
return erros;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,65 +1,64 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class EnvelopeRepository : CRUDRepository<Envelope, int, EGDbContext>, IEnvelopeRepository
|
||||||
{
|
{
|
||||||
public class EnvelopeRepository : CRUDRepository<Envelope, int, EGDbContext>, IEnvelopeRepository
|
public EnvelopeRepository(EGDbContext dbContext) : base(dbContext, dbContext.Envelopes)
|
||||||
{
|
{
|
||||||
public EnvelopeRepository(EGDbContext dbContext) : base(dbContext, dbContext.Envelopes)
|
}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false)
|
public async Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false)
|
||||||
{
|
{
|
||||||
var query = _dbSet.AsNoTracking();
|
var query = _dbSet.AsNoTracking();
|
||||||
|
|
||||||
if (documents)
|
if (documents)
|
||||||
if (documentReceiverElement)
|
if (documentReceiverElement)
|
||||||
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
|
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
|
||||||
else
|
else
|
||||||
query = query.Include(e => e.Documents);
|
query = query.Include(e => e.Documents);
|
||||||
|
|
||||||
if (history)
|
if (history)
|
||||||
query = query.Include(e => e.History);
|
query = query.Include(e => e.History);
|
||||||
|
|
||||||
return await query.ToListAsync();
|
return await query.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false)
|
public async Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false)
|
||||||
{
|
{
|
||||||
var query = _dbSet.AsNoTracking().Where(e => e.Uuid == uuid);
|
var query = _dbSet.AsNoTracking().Where(e => e.Uuid == uuid);
|
||||||
|
|
||||||
if (withAll || withDocuments)
|
if (withAll || withDocuments)
|
||||||
if (withAll || withDocumentReceiverElement)
|
if (withAll || withDocumentReceiverElement)
|
||||||
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
|
query = query.Include(e => e.Documents!).ThenInclude(d => d.Elements);
|
||||||
else
|
else
|
||||||
query = query.Include(e => e.Documents);
|
query = query.Include(e => e.Documents);
|
||||||
|
|
||||||
if (withAll || withUser)
|
if (withAll || withUser)
|
||||||
query = query.Include(e => e.User!);
|
query = query.Include(e => e.User!);
|
||||||
|
|
||||||
if (withAll || withHistory)
|
if (withAll || withHistory)
|
||||||
query = query.Include(e => e.History);
|
query = query.Include(e => e.History);
|
||||||
|
|
||||||
return await query.FirstOrDefaultAsync();
|
return await query.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
public async Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
||||||
{
|
{
|
||||||
var query = _dbSet.AsNoTracking().Where(e => e.UserId == userId);
|
var query = _dbSet.AsNoTracking().Where(e => e.UserId == userId);
|
||||||
|
|
||||||
if (min_status is not null)
|
if (min_status is not null)
|
||||||
query = query.Where(e => e.Status >= min_status);
|
query = query.Where(e => e.Status >= min_status);
|
||||||
|
|
||||||
if (max_status is not null)
|
if (max_status is not null)
|
||||||
query = query.Where(e => e.Status <= max_status);
|
query = query.Where(e => e.Status <= max_status);
|
||||||
|
|
||||||
foreach (var ignore_status in ignore_statuses)
|
foreach (var ignore_status in ignore_statuses)
|
||||||
query = query.Where(e => e.Status != ignore_status);
|
query = query.Where(e => e.Status != ignore_status);
|
||||||
|
|
||||||
return await query.ToListAsync();
|
return await query.ToListAsync();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,13 +1,12 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class EnvelopeTypeRepository : CRUDRepository<EnvelopeType, int, EGDbContext>, IEnvelopeTypeRepository
|
||||||
{
|
{
|
||||||
public class EnvelopeTypeRepository : CRUDRepository<EnvelopeType, int, EGDbContext>, IEnvelopeTypeRepository
|
public EnvelopeTypeRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeTypes)
|
||||||
{
|
{
|
||||||
public EnvelopeTypeRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeTypes)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,87 +1,86 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class EnvelopeReceiverRepository : CRUDRepository<EnvelopeReceiver, (int Envelope, int Receiver), EGDbContext>, IEnvelopeReceiverRepository
|
||||||
{
|
{
|
||||||
public class EnvelopeReceiverRepository : CRUDRepository<EnvelopeReceiver, (int Envelope, int Receiver), EGDbContext>, IEnvelopeReceiverRepository
|
public EnvelopeReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeReceivers)
|
||||||
{
|
{
|
||||||
public EnvelopeReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeReceivers)
|
}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private IQueryable<EnvelopeReceiver> ReadWhere(string? uuid = null, string? signature = null, bool withEnvelope = false, bool withReceiver = false, bool readOnly = true)
|
private IQueryable<EnvelopeReceiver> ReadWhere(string? uuid = null, string? signature = null, bool withEnvelope = false, bool withReceiver = false, bool readOnly = true)
|
||||||
{
|
{
|
||||||
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet;
|
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet;
|
||||||
|
|
||||||
if (uuid is not null)
|
if (uuid is not null)
|
||||||
query = query.Where(er => er.Envelope != null && er.Envelope.Uuid == uuid);
|
query = query.Where(er => er.Envelope != null && er.Envelope.Uuid == uuid);
|
||||||
|
|
||||||
if (signature is not null)
|
if (signature is not null)
|
||||||
query = query.Where(er => er.Receiver != null && er.Receiver.Signature == signature);
|
query = query.Where(er => er.Receiver != null && er.Receiver.Signature == signature);
|
||||||
|
|
||||||
if (withEnvelope)
|
if (withEnvelope)
|
||||||
query = query
|
query = query
|
||||||
.Include(er => er.Envelope).ThenInclude(e => e!.Documents!).ThenInclude(d => d.Elements!.Where(e => signature == null || e.Receiver!.Signature == signature))
|
.Include(er => er.Envelope).ThenInclude(e => e!.Documents!).ThenInclude(d => d.Elements!.Where(e => signature == null || e.Receiver!.Signature == signature))
|
||||||
.Include(er => er.Envelope).ThenInclude(e => e!.History)
|
.Include(er => er.Envelope).ThenInclude(e => e!.History)
|
||||||
.Include(er => er.Envelope).ThenInclude(e => e!.User);
|
.Include(er => er.Envelope).ThenInclude(e => e!.User);
|
||||||
|
|
||||||
if (withReceiver)
|
if (withReceiver)
|
||||||
query = query.Include(er => er.Receiver);
|
query = query.Include(er => er.Receiver);
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<EnvelopeReceiver>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true)
|
public async Task<IEnumerable<EnvelopeReceiver>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false, bool readOnly = true)
|
||||||
=> await ReadWhere(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).ToListAsync();
|
=> await ReadWhere(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).ToListAsync();
|
||||||
|
|
||||||
public async Task<IEnumerable<EnvelopeReceiver>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true)
|
public async Task<IEnumerable<EnvelopeReceiver>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true, bool readOnly = true)
|
||||||
=> await ReadWhere(signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).ToListAsync();
|
=> await ReadWhere(signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).ToListAsync();
|
||||||
|
|
||||||
public async Task<EnvelopeReceiver?> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
|
public async Task<EnvelopeReceiver?> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true, bool readOnly = true)
|
||||||
=> await ReadWhere(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).FirstOrDefaultAsync();
|
=> await ReadWhere(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver, readOnly: readOnly).FirstOrDefaultAsync();
|
||||||
|
|
||||||
public async Task<string?> ReadAccessCodeAsync(string uuid, string signature, bool readOnly = true)
|
public async Task<string?> ReadAccessCodeAsync(string uuid, string signature, bool readOnly = true)
|
||||||
=> await ReadWhere(uuid: uuid, signature: signature, readOnly: readOnly)
|
=> await ReadWhere(uuid: uuid, signature: signature, readOnly: readOnly)
|
||||||
.Select(er => er.AccessCode)
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
public async Task<int> CountAsync(string uuid, string signature) => await ReadWhere(uuid: uuid, signature: signature).CountAsync();
|
|
||||||
|
|
||||||
private IQueryable<EnvelopeReceiver> ReadById(int envelopeId, int receiverId, bool readOnly = true)
|
|
||||||
{
|
|
||||||
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet;
|
|
||||||
return query.Where(er => er.EnvelopeId == envelopeId && er.ReceiverId == receiverId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = true)
|
|
||||||
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId, readOnly: readOnly)
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
public async Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = true)
|
|
||||||
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId, readOnly: readOnly)
|
|
||||||
.Select(er => er.AccessCode)
|
.Select(er => er.AccessCode)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
public async Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
public async Task<int> CountAsync(string uuid, string signature) => await ReadWhere(uuid: uuid, signature: signature).CountAsync();
|
||||||
{
|
|
||||||
var query = _dbSet.AsNoTracking().Where(er => er.Envelope!.User!.Username == username);
|
|
||||||
|
|
||||||
if (min_status is not null)
|
private IQueryable<EnvelopeReceiver> ReadById(int envelopeId, int receiverId, bool readOnly = true)
|
||||||
query = query.Where(er => er.Envelope!.Status >= min_status);
|
{
|
||||||
|
var query = readOnly ? _dbSet.AsNoTracking() : _dbSet;
|
||||||
if (max_status is not null)
|
return query.Where(er => er.EnvelopeId == envelopeId && er.ReceiverId == receiverId);
|
||||||
query = query.Where(er => er.Envelope!.Status <= max_status);
|
|
||||||
|
|
||||||
foreach (var ignore_status in ignore_statuses)
|
|
||||||
query = query.Where(er => er.Envelope!.Status != ignore_status);
|
|
||||||
|
|
||||||
return await query.Include(er => er.Envelope).Include(er => er.Receiver).ToListAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<EnvelopeReceiver?> ReadLastByReceiver(string email)
|
|
||||||
{
|
|
||||||
return await _dbSet.Where(er => er.Receiver!.EmailAddress == email).OrderBy(er => er.EnvelopeId).LastOrDefaultAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<EnvelopeReceiver?> ReadByIdAsync(int envelopeId, int receiverId, bool readOnly = true)
|
||||||
|
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId, readOnly: readOnly)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
public async Task<string?> ReadAccessCodeByIdAsync(int envelopeId, int receiverId, bool readOnly = true)
|
||||||
|
=> await ReadById(envelopeId: envelopeId, receiverId: receiverId, readOnly: readOnly)
|
||||||
|
.Select(er => er.AccessCode)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
public async Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses)
|
||||||
|
{
|
||||||
|
var query = _dbSet.AsNoTracking().Where(er => er.Envelope!.User!.Username == username);
|
||||||
|
|
||||||
|
if (min_status is not null)
|
||||||
|
query = query.Where(er => er.Envelope!.Status >= min_status);
|
||||||
|
|
||||||
|
if (max_status is not null)
|
||||||
|
query = query.Where(er => er.Envelope!.Status <= max_status);
|
||||||
|
|
||||||
|
foreach (var ignore_status in ignore_statuses)
|
||||||
|
query = query.Where(er => er.Envelope!.Status != ignore_status);
|
||||||
|
|
||||||
|
return await query.Include(er => er.Envelope).Include(er => er.Receiver).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<EnvelopeReceiver?> ReadLastByReceiver(string email)
|
||||||
|
{
|
||||||
|
return await _dbSet.Where(er => er.Receiver!.EmailAddress == email).OrderBy(er => er.EnvelopeId).LastOrDefaultAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,37 +1,36 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class ReceiverRepository : CRUDRepository<Receiver, int, EGDbContext>, IReceiverRepository
|
||||||
{
|
{
|
||||||
public class ReceiverRepository : CRUDRepository<Receiver, int, EGDbContext>, IReceiverRepository
|
public ReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.Receivers)
|
||||||
{
|
{
|
||||||
public ReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.Receivers)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IQueryable<Receiver> ReadBy(string? emailAddress = null, string? signature = null, bool withLastUsedName = true)
|
|
||||||
{
|
|
||||||
IQueryable<Receiver> query = _dbSet.AsNoTracking();
|
|
||||||
|
|
||||||
if(emailAddress is not null)
|
|
||||||
query = query.Where(r => r.EmailAddress == emailAddress);
|
|
||||||
|
|
||||||
if(signature is not null)
|
|
||||||
query = query.Where(r => r.Signature == signature);
|
|
||||||
|
|
||||||
// envelope receivers are ignored (with '[JsonIgnore]' attribute). The reson to add them is to get the las used receiver name
|
|
||||||
if (withLastUsedName)
|
|
||||||
{
|
|
||||||
query = query.Include(r => r.EnvelopeReceivers!.OrderByDescending(er => er.EnvelopeId).Take(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Receiver?> ReadByAsync(string? emailAddress = null, string? signature = null) => await ReadBy(emailAddress, signature).FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
public async override Task<IEnumerable<Receiver>> ReadAllAsync() => await ReadBy().ToListAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IQueryable<Receiver> ReadBy(string? emailAddress = null, string? signature = null, bool withLastUsedName = true)
|
||||||
|
{
|
||||||
|
IQueryable<Receiver> query = _dbSet.AsNoTracking();
|
||||||
|
|
||||||
|
if(emailAddress is not null)
|
||||||
|
query = query.Where(r => r.EmailAddress == emailAddress);
|
||||||
|
|
||||||
|
if(signature is not null)
|
||||||
|
query = query.Where(r => r.Signature == signature);
|
||||||
|
|
||||||
|
// envelope receivers are ignored (with '[JsonIgnore]' attribute). The reson to add them is to get the las used receiver name
|
||||||
|
if (withLastUsedName)
|
||||||
|
{
|
||||||
|
query = query.Include(r => r.EnvelopeReceivers!.OrderByDescending(er => er.EnvelopeId).Take(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Receiver?> ReadByAsync(string? emailAddress = null, string? signature = null) => await ReadBy(emailAddress, signature).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
public async override Task<IEnumerable<Receiver>> ReadAllAsync() => await ReadBy().ToListAsync();
|
||||||
}
|
}
|
||||||
@ -1,13 +1,12 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Infrastructure.Repositories
|
namespace EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class UserReceiverRepository : CRUDRepository<UserReceiver, int, EGDbContext>, IUserReceiverRepository
|
||||||
{
|
{
|
||||||
public class UserReceiverRepository : CRUDRepository<UserReceiver, int, EGDbContext>, IUserReceiverRepository
|
public UserReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.UserReceivers)
|
||||||
{
|
{
|
||||||
public UserReceiverRepository(EGDbContext dbContext) : base(dbContext, dbContext.UserReceivers)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user