Refactor DocReceiverElement handling and add draft workflow

Removed `IDocReceiverElementWriter` interface and its implementation, replacing it with repository-based operations (`IRepository<DocReceiverElement>`). Updated `CreateEnvelopeCommandHandler` to use repository methods for deleting and creating `DocReceiverElement` records.

Cleaned up dependency injection by removing `IDocReceiverElementWriter` registration. Added new database triggers for `DocReceiverElement` in `appsettings.json` and `appsettings.Database.json`.

Introduced `SENDER_SAVE_EDIT_MIGRATION_PLAN.md` to outline the migration of the sender save/edit workflow to Blazor Server. This includes splitting save and send actions, supporting draft persistence, and enabling draft editing from the dashboard.

Removed unused namespaces and performed code cleanup. Updated testing strategies to ensure correctness and prevent regressions.
This commit is contained in:
2026-09-27 19:56:02 +02:00
parent 3dc9a180d3
commit a7d0b40e39
7 changed files with 288 additions and 75 deletions

View File

@@ -12,11 +12,9 @@ using DigitalData.UserManager.Domain.Entities;
using CommandDotNet.Execution;
using EnvelopeGenerator.Infrastructure.Repositories;
using EnvelopeGenerator.Infrastructure.Executor;
using EnvelopeGenerator.Infrastructure.Writers;
using EnvelopeGenerator.Application.Common.Interfaces.Repositories;
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
using EnvelopeGenerator.Application.Common.Interfaces.Services;
using EnvelopeGenerator.Application.Common.Interfaces;
using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
#elif NETFRAMEWORK
using System;
@@ -58,7 +56,6 @@ namespace EnvelopeGenerator.Infrastructure
services.TryAddScoped<IEnvelopeTypeRepository, EnvelopeTypeRepository>();
services.TryAddScoped<IReceiverRepository, ReceiverRepository>();
services.TryAddScoped<IEnvelopeReceiverReadOnlyRepository, EnvelopeReceiverReadOnlyRepository>();
services.TryAddScoped<IDocReceiverElementWriter, DocReceiverElementWriter>();
// User Preferences — distributed cache (dbo.TBDD_CACHE)
services.TryAddScoped<IUserPreferencesService, UserPreferencesService>();

View File

@@ -1,56 +0,0 @@
#if NET
using EnvelopeGenerator.Application.Common.Interfaces;
using EnvelopeGenerator.Domain.Entities;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Writers;
public class DocReceiverElementWriter(EGDbContext dbContext) : IDocReceiverElementWriter
{
public Task DeleteByDocumentAndReceiverAsync(int documentId, int receiverId, CancellationToken cancellationToken = default)
{
return dbContext.Database.ExecuteSqlInterpolatedAsync(
$"DELETE FROM [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] WHERE [DOCUMENT_ID] = {documentId} AND [RECEIVER_ID] = {receiverId}",
cancellationToken);
}
public Task InsertAsync(DocReceiverElement element, CancellationToken cancellationToken = default)
{
return dbContext.Database.ExecuteSqlInterpolatedAsync($@"
INSERT INTO [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT]
([DOCUMENT_ID]
,[RECEIVER_ID]
,[ELEMENT_TYPE]
,[POSITION_X]
,[POSITION_Y]
,[WIDTH]
,[HEIGHT]
,[REQUIRED]
,[READ_ONLY]
,[PAGE]
,[ADDED_WHEN]
,[FULL_NAME]
,[POSITION]
,[PLACE]
,[TOOLTIP]
,[ANNOTATION_INDEX])
VALUES ({element.DocumentId}
,{element.ReceiverId}
,{element.ElementType}
,{element.X}
,{element.Y}
,{element.Width}
,{element.Height}
,{element.Required}
,{element.ReadOnly}
,{element.Page}
,{element.AddedWhen}
,{element.FullName}
,{element.Position}
,{element.Place}
,{element.Tooltip}
,{element.AnnotationIndex})",
cancellationToken);
}
}
#endif