refactor(EnvelopeDocument): rename as Document

This commit is contained in:
tekh 2025-09-09 18:56:55 +02:00
parent fbbc05814f
commit ae669d05e7
23 changed files with 51 additions and 51 deletions

View File

@ -28,7 +28,7 @@ public class MappingProfile : Profile
CreateMap<DocumentStatus, DocumentStatusDto>();
CreateMap<EmailTemplate, EmailTemplateDto>();
CreateMap<Envelope, EnvelopeDto>();
CreateMap<EnvelopeDocument, DocumentDto>();
CreateMap<Document, DocumentDto>();
CreateMap<EnvelopeHistory, EnvelopeHistoryDto>();
CreateMap<EnvelopeHistory, EnvelopeHistoryCreateDto>();
CreateMap<EnvelopeReceiver, EnvelopeReceiverDto>();
@ -44,7 +44,7 @@ public class MappingProfile : Profile
CreateMap<DocumentStatusDto, DocumentStatus>();
CreateMap<EmailTemplateDto, EmailTemplate>();
CreateMap<EnvelopeDto, Envelope>();
CreateMap<DocumentDto, EnvelopeDocument>();
CreateMap<DocumentDto, Document>();
CreateMap<EnvelopeHistoryDto, EnvelopeHistory>();
CreateMap<EnvelopeHistoryCreateDto, EnvelopeHistory>();
CreateMap<EnvelopeReceiverDto, EnvelopeReceiver>();

View File

@ -8,7 +8,7 @@ namespace EnvelopeGenerator.Application.Common.SQL;
/// <summary>
///
/// </summary>
public class DocumentCreateReadSQL : ISQL<EnvelopeDocument>
public class DocumentCreateReadSQL : ISQL<Document>
{
/// <summary>
/// Base64, OUT_UID

View File

@ -17,23 +17,23 @@ public record ReadDocumentQuery(int? Id = null, int? EnvelopeId = null) : IReque
}
/// <summary>
/// Handles queries for reading <see cref="EnvelopeDocument"/> data based on either the document ID or the envelope ID.
/// Handles queries for reading <see cref="Document"/> data based on either the document ID or the envelope ID.
/// </summary>
public class ReadDocumentQueryHandler : IRequestHandler<ReadDocumentQuery, DocumentDto?>
{
/// <summary>
/// TempRepo for accessing <see cref="EnvelopeDocument"/> entities.
/// TempRepo for accessing <see cref="Document"/> entities.
/// </summary>
private readonly IRepository<EnvelopeDocument> _repo;
private readonly IRepository<Document> _repo;
private readonly IMapper _mapper;
/// <summary>
/// Initializes a new instance of the <see cref="ReadDocumentQueryHandler"/> class.
/// </summary>
/// <param name="envelopeDocumentRepository">The repository used to access <see cref="EnvelopeDocument"/> entities.</param>
/// <param name="envelopeDocumentRepository">The repository used to access <see cref="Document"/> entities.</param>
/// <param name="mapper"></param>
public ReadDocumentQueryHandler(IRepository<EnvelopeDocument> envelopeDocumentRepository, IMapper mapper)
public ReadDocumentQueryHandler(IRepository<Document> envelopeDocumentRepository, IMapper mapper)
{
_repo = envelopeDocumentRepository;
_mapper = mapper;

View File

@ -7,6 +7,6 @@ namespace EnvelopeGenerator.Application.Interfaces.Repositories;
///
/// </summary>
[Obsolete("Use IRepository")]
public interface IEnvelopeDocumentRepository : ICRUDRepository<EnvelopeDocument, int>
public interface IEnvelopeDocumentRepository : ICRUDRepository<Document, int>
{
}

View File

@ -14,5 +14,5 @@ public interface IDocumentExecutor
/// <param name="envelope_uuid"></param>
/// <param name="cancellation"></param>
/// <returns></returns>
Task<EnvelopeDocument> CreateDocumentAsync(string base64, string envelope_uuid, CancellationToken cancellation = default);
Task<Document> CreateDocumentAsync(string base64, string envelope_uuid, CancellationToken cancellation = default);
}

View File

@ -8,6 +8,6 @@ namespace EnvelopeGenerator.Application.Interfaces.Services;
///
/// </summary>
[Obsolete("Use MediatR")]
public interface IEnvelopeDocumentService : IBasicCRUDService<DocumentDto, EnvelopeDocument, int>
public interface IEnvelopeDocumentService : IBasicCRUDService<DocumentDto, Document, int>
{
}

View File

@ -11,7 +11,7 @@ namespace EnvelopeGenerator.Application.Services;
///
/// </summary>
[Obsolete("Use MediatR")]
public class EnvelopeDocumentService : BasicCRUDService<IEnvelopeDocumentRepository, DocumentDto, EnvelopeDocument, int>, IEnvelopeDocumentService
public class EnvelopeDocumentService : BasicCRUDService<IEnvelopeDocumentRepository, DocumentDto, Document, int>, IEnvelopeDocumentService
{
/// <summary>
///

View File

@ -12,14 +12,14 @@ Public Class DocumentModel
ElementModel = New ElementModel(pState)
End Sub
Private Function ToDocument(pRow As DataRow) As EnvelopeDocument
Private Function ToDocument(pRow As DataRow) As Document
Return ToDocument(pRow, 0)
End Function
Private Function ToDocument(pRow As DataRow, pReceiverId As Integer) As EnvelopeDocument
Private Function ToDocument(pRow As DataRow, pReceiverId As Integer) As Document
Dim oDocumentId = pRow.ItemEx("GUID", 0)
Dim byteDataObj = pRow.Item("BYTE_DATA")
Return New EnvelopeDocument() With {
Return New Document() With {
.Id = oDocumentId,
.EnvelopeId = pRow.ItemEx("ENVELOPE_ID", 0),
.Filename = pRow.ItemEx("FILENAME", ""),
@ -31,7 +31,7 @@ Public Class DocumentModel
}
End Function
Public Function GetById(pDocumentId As Integer) As EnvelopeDocument
Public Function GetById(pDocumentId As Integer) As Document
Try
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE_DOCUMENT] WHERE GUID = {pDocumentId}"
Dim oTable = Database.GetDatatable(oSql)
@ -46,7 +46,7 @@ Public Class DocumentModel
End Try
End Function
Public Function List(pEnvelopeId As Integer) As IEnumerable(Of EnvelopeDocument)
Public Function List(pEnvelopeId As Integer) As IEnumerable(Of Document)
Try
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE_DOCUMENT] WHERE ENVELOPE_ID = {pEnvelopeId}"
Dim oTable = Database.GetDatatable(oSql)
@ -61,7 +61,7 @@ Public Class DocumentModel
End Try
End Function
Public Function List(pEnvelopeId As Integer, pReceiverId As Integer) As IEnumerable(Of EnvelopeDocument)
Public Function List(pEnvelopeId As Integer, pReceiverId As Integer) As IEnumerable(Of Document)
Try
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE_DOCUMENT] WHERE ENVELOPE_ID = {pEnvelopeId}"
Dim oTable = Database.GetDatatable(oSql)
@ -76,7 +76,7 @@ Public Class DocumentModel
End Try
End Function
Public Function Insert(pEnvelope As Envelope, pDocument As EnvelopeDocument, pTransaction As SqlTransaction) As Boolean
Public Function Insert(pEnvelope As Envelope, pDocument As Document, pTransaction As SqlTransaction) As Boolean
Try
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_DOCUMENT]
([FILENAME]

View File

@ -14,9 +14,9 @@ namespace EnvelopeGenerator.Domain.Entities
#endif
[Table("TBSIG_ENVELOPE_DOCUMENT", Schema = "dbo")]
public class EnvelopeDocument
public class Document
{
public EnvelopeDocument()
public Document()
{
#if NETFRAMEWORK
Elements = Enumerable.Empty<DocumentReceiverElement>().ToList();

View File

@ -103,7 +103,7 @@ public class DocumentReceiverElement
ChangedWho { get; set; }
[ForeignKey("DocumentId")]
public virtual EnvelopeDocument Document { get; set; }
public virtual Document Document { get; set; }
[ForeignKey("ReceiverId")]
public virtual Receiver Receiver { get; set; }

View File

@ -35,7 +35,7 @@ public class Envelope
ReminderIntervalDays = 0;
CertificationType = (int)Constants.CertificationType.AdvancedElectronicSignature;
UseAccessCode = false;
Documents = Enumerable.Empty<EnvelopeDocument>().ToList();
Documents = Enumerable.Empty<Document>().ToList();
Histories = Enumerable.Empty<EnvelopeHistory>().ToList();
EnvelopeReceivers = Enumerable.Empty<EnvelopeReceiver>().ToList();
#endif
@ -158,7 +158,7 @@ public class Envelope
public bool IsAlreadySent => Status > EnvelopeStatus.EnvelopeSaved;
#endif
public List<EnvelopeDocument>
public List<Document>
#if NET
?
#endif

View File

@ -100,7 +100,7 @@ Public MustInherit Class BaseController
End Try
End Function
Public Function DeleteDocument(pDocument As EnvelopeDocument, pTransaction As SqlTransaction) As Boolean
Public Function DeleteDocument(pDocument As Document, pTransaction As SqlTransaction) As Boolean
Try
If DocumentModel.Delete(pDocument.Id, pTransaction) = True Then
@ -137,7 +137,7 @@ Public MustInherit Class BaseController
End Function
Public Function DeleteDocumentFromDisk(pDocument As EnvelopeDocument) As Boolean
Public Function DeleteDocumentFromDisk(pDocument As Document) As Boolean
Try
If IO.File.Exists(pDocument.Filepath) Then
IO.File.Delete(pDocument.Filepath)

View File

@ -159,7 +159,7 @@ Public Class EnvelopeEditorController
End Try
End Function
Public Async Function CreateDocument(pDocumentFilePath As String) As Threading.Tasks.Task(Of EnvelopeDocument)
Public Async Function CreateDocument(pDocumentFilePath As String) As Threading.Tasks.Task(Of Document)
Try
Dim oFixedPath = FixPageRotation.FixPageRotation(pDocumentFilePath)
If oFixedPath <> pDocumentFilePath Then
@ -177,7 +177,7 @@ Public Class EnvelopeEditorController
Dim oFileInfoTemp = New FileInfo(oTempFilePath)
Dim oDocument = New EnvelopeDocument() With {
Dim oDocument = New Document() With {
.Filename = oFileInfoTemp.Name,
.Filepath = oFileInfoTemp.FullName,
.FileNameOriginal = oFileInfo.Name,
@ -230,7 +230,7 @@ Public Class EnvelopeEditorController
End Try
End Function
Public Overloads Function DeleteDocument(pDocument As EnvelopeDocument) As Boolean
Public Overloads Function DeleteDocument(pDocument As Document) As Boolean
Dim oConnection As SqlConnection = Database.GetConnection
Dim oTransaction As SqlTransaction = oConnection.BeginTransaction

View File

@ -7,7 +7,7 @@ Imports EnvelopeGenerator.Domain.Entities
Public Class FieldEditorController
Inherits BaseController
Private ReadOnly Document As EnvelopeDocument
Private ReadOnly Document As Document
Public Property Elements As New List(Of DocumentReceiverElement)
Public Class ElementInfo
@ -16,7 +16,7 @@ Public Class FieldEditorController
Public Guid As Integer
End Class
Public Sub New(pState As State, pDocument As EnvelopeDocument)
Public Sub New(pState As State, pDocument As Document)
MyBase.New(pState)
Document = pDocument

View File

@ -17,7 +17,7 @@ Imports EnvelopeGenerator.Domain.Entities
Partial Public Class frmEnvelopeEditor
Public Property Envelope As Envelope
Public Property Documents As New BindingList(Of EnvelopeDocument)
Public Property Documents As New BindingList(Of Document)
Public Property Receivers As New BindingList(Of ReceiverVM)
Private AllReceiverEmails As New List(Of String)
@ -104,10 +104,10 @@ Partial Public Class frmEnvelopeEditor
End If
Else
Controller = New EnvelopeEditorController(State, Envelope)
Documents = New BindingList(Of EnvelopeDocument)(Controller.Envelope.Documents)
Documents = New BindingList(Of Document)(Controller.Envelope.Documents)
Receivers = New BindingList(Of ReceiverVM)(Controller.Envelope.EnvelopeReceivers.Select(Function(r) ReceiverVM.From(r)).ToList())
For Each docItem As EnvelopeDocument In Documents
For Each docItem As Document In Documents
If Not File.Exists(docItem.Filepath) Then
Dim oTempFolder = TempFiles._TempPath
Dim oTempFilename = String.Concat(oTempFolder, "\", $"ViewEnvDoc_{Envelope.Id}.pdf")
@ -183,7 +183,7 @@ Partial Public Class frmEnvelopeEditor
Exit Sub
End If
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
Dim oDocument As Document = DirectCast(ViewDocuments.GetFocusedRow(), Document)
If Controller.DeleteDocument(oDocument) Then
Documents.Remove(oDocument)
GridDocuments.DataSource = Nothing
@ -213,7 +213,7 @@ Partial Public Class frmEnvelopeEditor
End If
If ViewDocuments.GetSelectedRows().Count > 0 Then
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
Dim oDocument As Document = DirectCast(ViewDocuments.GetFocusedRow(), Document)
Dim oEnvelope = Controller.Envelope
If Not IsNothing(oDocument.ByteData) Then
Dim oTempFolder = TempFiles._TempPath

View File

@ -18,7 +18,7 @@ Partial Public Class frmFieldEditor
Private Manager As AnnotationManager
Private Controller As FieldEditorController
Public Property Document As EnvelopeDocument = Nothing
Public Property Document As Document = Nothing
Public Property Receivers As List(Of ReceiverVM)
Public Property SelectedReceiver As ReceiverVM = Nothing

View File

@ -623,7 +623,7 @@ Public Class frmMain
Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle)
Dim oController = New EnvelopeEditorController(State, oEnvelope)
Dim Documents As New BindingList(Of EnvelopeDocument)
Dim Documents As New BindingList(Of Document)
Dim Receivers = New BindingList(Of ReceiverVM)(oController.Envelope.EnvelopeReceivers.Select(Function(r) ReceiverVM.From(r)).ToList())
For Each oReceiver As ReceiverVM In Receivers
If oReceiver.EmailAddress = selReceiver.EmailAddress Then
@ -871,7 +871,7 @@ Public Class frmMain
Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle)
If oEnvelope.UseAccessCode = True Then
Dim oController = New EnvelopeEditorController(State, oEnvelope)
Dim Documents As New BindingList(Of EnvelopeDocument)
Dim Documents As New BindingList(Of Document)
Dim Receivers = New BindingList(Of ReceiverVM)(oController.Envelope.EnvelopeReceivers.Select(Function(r) ReceiverVM.From(r)).ToList())
For Each oReceiver As ReceiverVM In Receivers
If oReceiver.EmailAddress = selReceiver.EmailAddress Then

View File

@ -58,7 +58,7 @@ public static class DIExtensions
services.AddDbRepository<EGDbContext, User>(context => context.Users).UseAutoMapper();
services.AddDbRepository<EGDbContext, Config>(context => context.Configs).UseAutoMapper();
services.AddDbRepository<EGDbContext, DocumentReceiverElement>(context => context.DocumentReceiverElements).UseAutoMapper();
services.AddDbRepository<EGDbContext, EnvelopeDocument>(context => context.EnvelopeDocument).UseAutoMapper();
services.AddDbRepository<EGDbContext, Document>(context => context.EnvelopeDocument).UseAutoMapper();
services.AddDbRepository<EGDbContext, DocumentStatus>(context => context.DocumentStatus).UseAutoMapper();
services.AddDbRepository<EGDbContext, EmailTemplate>(context => context.EmailTemplate).UseAutoMapper();
services.AddDbRepository<EGDbContext, EmailOut>(context => context.EMailOuts).UseAutoMapper();
@ -71,14 +71,14 @@ public static class DIExtensions
services.AddSQLExecutor<Envelope>();
services.AddSQLExecutor<Receiver>();
services.AddSQLExecutor<EnvelopeDocument>();
services.AddSQLExecutor<Document>();
services.AddSQLExecutor<DocumentReceiverElement>();
services.AddSQLExecutor<DocumentStatus>();
SetDapperTypeMap<Envelope>();
SetDapperTypeMap<User>();
SetDapperTypeMap<Receiver>();
SetDapperTypeMap<EnvelopeDocument>();
SetDapperTypeMap<Document>();
SetDapperTypeMap<DocumentReceiverElement>();
SetDapperTypeMap<DocumentStatus>();

View File

@ -29,7 +29,7 @@ public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
public DbSet<EmailTemplate> EmailTemplate { get; set; }
public DbSet<EnvelopeDocument> EnvelopeDocument { get; set; }
public DbSet<Document> EnvelopeDocument { get; set; }
public DbSet<EnvelopeHistory> EnvelopeHistories { get; set; }
@ -71,7 +71,7 @@ public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
Envelopes = Set<Envelope>();
DocumentReceiverElements = Set<DocumentReceiverElement>();
DocumentStatus = Set<DocumentStatus>();
EnvelopeDocument = Set<EnvelopeDocument>();
EnvelopeDocument = Set<Document>();
EnvelopeHistories = Set<EnvelopeHistory>();
EnvelopeTypes = Set<EnvelopeType>();
Receivers = Set<Receiver>();
@ -132,7 +132,7 @@ public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
#endregion Receiver
#region EnvelopeDocument
modelBuilder.Entity<EnvelopeDocument>()
modelBuilder.Entity<Document>()
.HasMany(ed => ed.Elements)
.WithOne(e => e.Document)
.HasForeignKey(e => e.DocumentId);
@ -197,7 +197,7 @@ public class EGDbContext : DbContext, IUserManagerDbContext, IMailDbContext
AddTrigger<DocumentStatus>();
AddTrigger<EmailTemplate>();
AddTrigger<Envelope>();
AddTrigger<EnvelopeDocument>();
AddTrigger<Document>();
AddTrigger<EnvelopeHistory>();
AddTrigger<EnvelopeReceiver>();
AddTrigger<EnvelopeReceiverReadOnly>();

View File

@ -14,14 +14,14 @@ public class DocumentExecutor : SQLExecutor, IDocumentExecutor
{
}
public async Task<EnvelopeDocument> CreateDocumentAsync(string base64, string envelope_uuid, CancellationToken cancellation = default)
public async Task<Document> CreateDocumentAsync(string base64, string envelope_uuid, CancellationToken cancellation = default)
{
using var connection = new SqlConnection(Params.ConnectionString);
var sql = Provider.GetRequiredService<DocumentCreateReadSQL>();
var formattedSql = string.Format(sql.Raw, envelope_uuid.ToSqlParam());
var param = DocumentCreateReadSQL.CreateParmas(base64);
await connection.OpenAsync(cancellation);
var documents = await connection.QueryAsync<EnvelopeDocument>(formattedSql, param);
var documents = await connection.QueryAsync<Document>(formattedSql, param);
return documents.FirstOrDefault()
?? throw new InvalidOperationException($"Document creation failed. Parameters:" +
$"base64={base64}, envelope_uuid='{envelope_uuid}'.");

View File

@ -5,7 +5,7 @@ using EnvelopeGenerator.Application.Interfaces.Repositories;
namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")]
public class EnvelopeDocumentRepository : CRUDRepository<EnvelopeDocument, int, EGDbContext>, IEnvelopeDocumentRepository
public class EnvelopeDocumentRepository : CRUDRepository<Document, int, EGDbContext>, IEnvelopeDocumentRepository
{
public EnvelopeDocumentRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeDocument)
{

View File

@ -192,7 +192,7 @@ public static class Extensions
string lorem = faker.Lorem.Paragraphs(2);
QuestPDF.Settings.License = LicenseType.Community;
var document = Document.Create(container =>
var document = QuestPDF.Fluent.Document.Create(container =>
{
container.Page(page =>
{

View File

@ -5,7 +5,7 @@ using EnvelopeGenerator.Application.Common.Dto;
namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")]
public class TestEnvelopeDocumentController : TestControllerBase<IEnvelopeDocumentService, DocumentDto, EnvelopeDocument, int>
public class TestEnvelopeDocumentController : TestControllerBase<IEnvelopeDocumentService, DocumentDto, Document, int>
{
public TestEnvelopeDocumentController(ILogger<TestEnvelopeDocumentController> logger, IEnvelopeDocumentService service) : base(logger, service)
{