Refactor: Replace EnvelopeType with EnvelopeTypeDefaults

Replaced the `EnvelopeType` class with `EnvelopeTypeDefaults` across the codebase to standardize the data model. Updated DTOs, repositories, services, mappings, and database contexts to reflect this change.

Key updates include:
- Updated `EnvelopeDto` to use `EnvelopeTypeDefaults`.
- Modified `IEnvelopeTypeRepository` and `IEnvelopeTypeService` interfaces.
- Adjusted mappings in `MappingProfile.cs` for `EnvelopeTypeDefaults`.
- Updated `ReadEnvelopeTypesQueryHandler` and `CreateEnvelopeCommandHandler` to use `EnvelopeTypeDefaults`.
- Replaced `EnvelopeType` with `EnvelopeTypeDefaults` in `EnvelopeTypeModel.vb`, `frmEnvelopeMainData.vb`, and `EGDbContextBase`.
- Introduced the `EnvelopeTypeDefaults` class with updated schema mappings.
- Updated `EnvelopeTypeRepository` and `TestEnvelopeTypeController` to use `EnvelopeTypeDefaults`.

These changes ensure consistency and improve maintainability across the application.
This commit is contained in:
2026-11-12 16:42:27 +01:00
parent 34b184b057
commit 621f9333a4
15 changed files with 24 additions and 24 deletions

View File

@@ -139,7 +139,7 @@ public record EnvelopeDto : IEnvelope
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public EnvelopeType? EnvelopeType { get; set; } public EnvelopeTypeDefaults? EnvelopeType { get; set; }
/// <summary> /// <summary>
/// ///

View File

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

View File

@@ -8,6 +8,6 @@ namespace EnvelopeGenerator.Application.Common.Interfaces.Services;
/// ///
/// </summary> /// </summary>
[Obsolete("Use MediatR")] [Obsolete("Use MediatR")]
public interface IEnvelopeTypeService : IBasicCRUDService<EnvelopeTypeDto, EnvelopeType, int> public interface IEnvelopeTypeService : IBasicCRUDService<EnvelopeTypeDto, EnvelopeTypeDefaults, int>
{ {
} }

View File

@@ -37,7 +37,7 @@ public class MappingProfile : Profile
CreateMap<History, HistoryCreateDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen)); CreateMap<History, HistoryCreateDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen));
CreateMap<EnvelopeReceiver, EnvelopeReceiverDto>(); CreateMap<EnvelopeReceiver, EnvelopeReceiverDto>();
CreateMap<EnvelopeReceiver, EnvelopeReceiverSecretDto>(); CreateMap<EnvelopeReceiver, EnvelopeReceiverSecretDto>();
CreateMap<EnvelopeType, EnvelopeTypeDto>(); CreateMap<EnvelopeTypeDefaults, EnvelopeTypeDto>();
CreateMap<Receiver, ReceiverDto>(); CreateMap<Receiver, ReceiverDto>();
CreateMap<EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>(); CreateMap<EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>();
CreateMap<ElementAnnotation, AnnotationDto>(); CreateMap<ElementAnnotation, AnnotationDto>();
@@ -55,7 +55,7 @@ public class MappingProfile : Profile
CreateMap<HistoryDto, History>().ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(src => src.ActionDate)); CreateMap<HistoryDto, History>().ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(src => src.ActionDate));
CreateMap<HistoryCreateDto, History>().ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(src => src.ActionDate)); CreateMap<HistoryCreateDto, History>().ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(src => src.ActionDate));
CreateMap<EnvelopeReceiverDto, EnvelopeReceiver>(); CreateMap<EnvelopeReceiverDto, EnvelopeReceiver>();
CreateMap<EnvelopeTypeDto, EnvelopeType>(); CreateMap<EnvelopeTypeDto, EnvelopeTypeDefaults>();
CreateMap<ReceiverDto, Receiver>().ForMember(rcv => rcv.EnvelopeReceivers, rcvReadDto => rcvReadDto.Ignore()); CreateMap<ReceiverDto, Receiver>().ForMember(rcv => rcv.EnvelopeReceivers, rcvReadDto => rcvReadDto.Ignore());
CreateMap<EnvelopeReceiverReadOnlyCreateDto, EnvelopeReceiverReadOnly>(); CreateMap<EnvelopeReceiverReadOnlyCreateDto, EnvelopeReceiverReadOnly>();
CreateMap<EnvelopeReceiverReadOnlyUpdateDto, EnvelopeReceiverReadOnly>(); CreateMap<EnvelopeReceiverReadOnlyUpdateDto, EnvelopeReceiverReadOnly>();

View File

@@ -16,13 +16,13 @@ public record ReadEnvelopeTypesQuery : IRequest<IEnumerable<EnvelopeTypeDto>>;
/// </summary> /// </summary>
public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQuery, IEnumerable<EnvelopeTypeDto>> public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQuery, IEnumerable<EnvelopeTypeDto>>
{ {
private readonly IRepository<EnvelopeType> _repository; private readonly IRepository<EnvelopeTypeDefaults> _repository;
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="repository"></param> /// <param name="repository"></param>
public ReadEnvelopeTypesQueryHandler(IRepository<EnvelopeType> repository) public ReadEnvelopeTypesQueryHandler(IRepository<EnvelopeTypeDefaults> repository)
{ {
_repository = repository; _repository = repository;
} }

View File

@@ -41,7 +41,7 @@ public class CreateEnvelopeCommandHandler(IServiceProvider Provider, IMapper Map
private IRepository<EnvelopeReceiver> EnvelopeReceiverRepository => Provider.GetRequiredService<IRepository<EnvelopeReceiver>>(); private IRepository<EnvelopeReceiver> EnvelopeReceiverRepository => Provider.GetRequiredService<IRepository<EnvelopeReceiver>>();
private IRepository<EnvelopeType> EnvelopeTypeRepository => Provider.GetRequiredService<IRepository<EnvelopeType>>(); private IRepository<EnvelopeTypeDefaults> EnvelopeTypeRepository => Provider.GetRequiredService<IRepository<EnvelopeTypeDefaults>>();
private IRepository<Receiver> ReceiverRepository => Provider.GetRequiredService<IRepository<Receiver>>(); private IRepository<Receiver> ReceiverRepository => Provider.GetRequiredService<IRepository<Receiver>>();
@@ -233,7 +233,7 @@ public class CreateEnvelopeCommandHandler(IServiceProvider Provider, IMapper Map
private async Task<EnvelopeSettings> ResolveEnvelopeSettingsAsync(CreateEnvelopeCommand request, Envelope? existing, CancellationToken cancel) private async Task<EnvelopeSettings> ResolveEnvelopeSettingsAsync(CreateEnvelopeCommand request, Envelope? existing, CancellationToken cancel)
{ {
EnvelopeType? selectedType = null; EnvelopeTypeDefaults? selectedType = null;
if (request.EnvelopeTypeId is int envelopeTypeId && envelopeTypeId > 0) if (request.EnvelopeTypeId is int envelopeTypeId && envelopeTypeId > 0)
{ {
selectedType = await EnvelopeTypeRepository.Query selectedType = await EnvelopeTypeRepository.Query

View File

@@ -14,7 +14,7 @@ namespace EnvelopeGenerator.Application.Services;
/// ///
/// </summary> /// </summary>
[Obsolete("Use MediatR")] [Obsolete("Use MediatR")]
public class EnvelopeTypeService : BasicCRUDService<IEnvelopeTypeRepository, EnvelopeTypeDto, EnvelopeType, int>, IEnvelopeTypeService public class EnvelopeTypeService : BasicCRUDService<IEnvelopeTypeRepository, EnvelopeTypeDto, EnvelopeTypeDefaults, int>, IEnvelopeTypeService
{ {
private static readonly Guid CacheKey = Guid.NewGuid(); private static readonly Guid CacheKey = Guid.NewGuid();

View File

@@ -8,8 +8,8 @@ Public Class EnvelopeTypeModel
MyBase.New(pState) MyBase.New(pState)
End Sub End Sub
Private Function ToEnvelopeType(pRow As DataRow) As EnvelopeType Private Function ToEnvelopeType(pRow As DataRow) As EnvelopeTypeDefaults
Return New EnvelopeType() With { Return New EnvelopeTypeDefaults() With {
.Id = pRow.ItemEx("GUID", 0), .Id = pRow.ItemEx("GUID", 0),
.Title = pRow.ItemEx("TITLE", ""), .Title = pRow.ItemEx("TITLE", ""),
.UseAccessCode = pRow.ItemEx("USE_ACCESS_CODE", False), .UseAccessCode = pRow.ItemEx("USE_ACCESS_CODE", False),
@@ -27,7 +27,7 @@ Public Class EnvelopeTypeModel
} }
End Function End Function
Public Function GetById(pEnvelopeTypeId As Integer) As EnvelopeType Public Function GetById(pEnvelopeTypeId As Integer) As EnvelopeTypeDefaults
Dim oSql As String = $"SELECT * FROM TBSIG_ENVELOPE_TYPE WHERE GUID = {pEnvelopeTypeId}" Dim oSql As String = $"SELECT * FROM TBSIG_ENVELOPE_TYPE WHERE GUID = {pEnvelopeTypeId}"
Dim oTable As DataTable = Database.GetDatatable(oSql) Dim oTable As DataTable = Database.GetDatatable(oSql)
@@ -39,7 +39,7 @@ Public Class EnvelopeTypeModel
Return ToEnvelopeType(oRow) Return ToEnvelopeType(oRow)
End Function End Function
Public Function List() As IEnumerable(Of EnvelopeType) Public Function List() As IEnumerable(Of EnvelopeTypeDefaults)
Dim oSql As String = $"SELECT * FROM TBSIG_ENVELOPE_TYPE" Dim oSql As String = $"SELECT * FROM TBSIG_ENVELOPE_TYPE"
Dim oTable As DataTable = Database.GetDatatable(oSql) Dim oTable As DataTable = Database.GetDatatable(oSql)

View File

@@ -150,7 +150,7 @@ namespace EnvelopeGenerator.Domain.Entities
{ get; set; } { get; set; }
[ForeignKey("EnvelopeTypeId")] [ForeignKey("EnvelopeTypeId")]
public virtual EnvelopeType public virtual EnvelopeTypeDefaults
#if nullable #if nullable
? ?
#endif #endif

View File

@@ -9,7 +9,7 @@ using System;
namespace EnvelopeGenerator.Domain.Entities namespace EnvelopeGenerator.Domain.Entities
{ {
[Table("TBSIG_ENVELOPE_TYPE", Schema = "dbo")] [Table("TBSIG_ENVELOPE_TYPE", Schema = "dbo")]
public class EnvelopeType public class EnvelopeTypeDefaults
{ {
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]

View File

@@ -14,7 +14,7 @@ Public Class frmEnvelopeMainData
Private Property EnvelopeTypeModel As EnvelopeTypeModel Private Property EnvelopeTypeModel As EnvelopeTypeModel
<Bindable(True)> <Bindable(True)>
Private Property EnvelopeType As New EnvelopeType Private Property EnvelopeType As New EnvelopeTypeDefaults
Public Property State As State Public Property State As State
@@ -121,7 +121,7 @@ Public Class frmEnvelopeMainData
Return Return
End If End If
Dim oEnvelopeType = DirectCast(cmbEnvelopeType.EditValue, EnvelopeType) Dim oEnvelopeType = DirectCast(cmbEnvelopeType.EditValue, EnvelopeTypeDefaults)
If IsNothing(oEnvelopeType) Then If IsNothing(oEnvelopeType) Then
oEnvelopeType = EnvelopeType oEnvelopeType = EnvelopeType
End If End If
@@ -162,7 +162,7 @@ Public Class frmEnvelopeMainData
End Sub End Sub
Private Sub cmbContractType_SelectedValueChanged(sender As Object, e As EventArgs) Handles cmbEnvelopeType.SelectedValueChanged Private Sub cmbContractType_SelectedValueChanged(sender As Object, e As EventArgs) Handles cmbEnvelopeType.SelectedValueChanged
Dim oSelectedType As EnvelopeType = cmbEnvelopeType.SelectedItem Dim oSelectedType As EnvelopeTypeDefaults = cmbEnvelopeType.SelectedItem
If oSelectedType Is Nothing Then If oSelectedType Is Nothing Then
Exit Sub Exit Sub

View File

@@ -57,7 +57,7 @@ public abstract class EGDbContextBase : DbContext
public DbSet<History> EnvelopeHistories { get; set; } public DbSet<History> EnvelopeHistories { get; set; }
public DbSet<EnvelopeType> EnvelopeTypes { get; set; } public DbSet<EnvelopeTypeDefaults> EnvelopeTypes { get; set; }
public DbSet<Receiver> Receivers { get; set; } public DbSet<Receiver> Receivers { get; set; }
@@ -233,7 +233,7 @@ public abstract class EGDbContextBase : DbContext
AddTrigger<History>(); AddTrigger<History>();
AddTrigger<EnvelopeReceiver>(); AddTrigger<EnvelopeReceiver>();
AddTrigger<EnvelopeReceiverReadOnly>(); AddTrigger<EnvelopeReceiverReadOnly>();
AddTrigger<EnvelopeType>(); AddTrigger<EnvelopeTypeDefaults>();
AddTrigger<Receiver>(); AddTrigger<Receiver>();
#if NET #if NET
AddTrigger<EmailOut>(); AddTrigger<EmailOut>();

View File

@@ -6,7 +6,7 @@ using EnvelopeGenerator.Application.Common.Interfaces.Repositories;
namespace EnvelopeGenerator.Infrastructure.Repositories; namespace EnvelopeGenerator.Infrastructure.Repositories;
[Obsolete("Use IRepository")] [Obsolete("Use IRepository")]
public class EnvelopeTypeRepository : CRUDRepository<EnvelopeType, int, EGDbContext>, IEnvelopeTypeRepository public class EnvelopeTypeRepository : CRUDRepository<EnvelopeTypeDefaults, int, EGDbContext>, IEnvelopeTypeRepository
{ {
public EnvelopeTypeRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeTypes) public EnvelopeTypeRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeTypes)
{ {

View File

@@ -628,7 +628,7 @@
private bool _createWizardVisible = false; private bool _createWizardVisible = false;
private IReadOnlyList<EnvelopeTypeDto> _envelopeTypes = []; private IReadOnlyList<EnvelopeTypeDto> _envelopeTypes = [];
// Stable keys used to store/restore each tab's layout in UserPreferences.GridLayouts // StableDefaults keys used to store/restore each tab's layout in UserPreferences.GridLayouts
private const string GridKeyActive = "sender.active-envelopes"; private const string GridKeyActive = "sender.active-envelopes";
private const string GridKeyCompleted = "sender.completed-envelopes"; private const string GridKeyCompleted = "sender.completed-envelopes";

View File

@@ -5,7 +5,7 @@ using EnvelopeGenerator.Application.Common.Interfaces.Services;
namespace EnvelopeGenerator.Web.Controllers.Test; namespace EnvelopeGenerator.Web.Controllers.Test;
[Obsolete("Use MediatR")] [Obsolete("Use MediatR")]
public class TestEnvelopeTypeController : TestControllerBase<IEnvelopeTypeService, EnvelopeTypeDto, EnvelopeType, int> public class TestEnvelopeTypeController : TestControllerBase<IEnvelopeTypeService, EnvelopeTypeDto, EnvelopeTypeDefaults, int>
{ {
public TestEnvelopeTypeController(ILogger<TestEnvelopeTypeController> logger, IEnvelopeTypeService service) : base(logger, service) public TestEnvelopeTypeController(ILogger<TestEnvelopeTypeController> logger, IEnvelopeTypeService service) : base(logger, service)
{ {