Refactor EnvelopeTypeDto to EnvelopeTypeDefaultsDto
Renamed `EnvelopeTypeDto` to `EnvelopeTypeDefaultsDto` to better reflect its purpose as a DTO for default envelope type configurations. Updated all references to `EnvelopeTypeDto` across the application, including: - Service interfaces (`IEnvelopeTypeService`) and implementations. - AutoMapper mappings in `MappingProfile.cs`. - Query handlers (`ReadEnvelopeTypesQuery` and `ReadEnvelopeTypesQueryHandler`). - Razor components (`CreateEnvelopeWizardPopup.razor`, `SenderEditorPage.razor`, `SenderPage.razor`). - Client-side services (`EnvelopeTypeService`). - Controller (`TestEnvelopeTypeController`). These changes ensure consistency and clarity in naming conventions while maintaining functionality.
This commit is contained in:
@@ -5,7 +5,7 @@ namespace EnvelopeGenerator.Application.Common.Dto;
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing a type of envelope with its configuration settings.
|
||||
/// </summary>
|
||||
public class EnvelopeTypeDto
|
||||
public class EnvelopeTypeDefaultsDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the envelope type.
|
||||
@@ -8,6 +8,6 @@ namespace EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||
///
|
||||
/// </summary>
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface IEnvelopeTypeService : IBasicCRUDService<EnvelopeTypeDto, EnvelopeTypeDefaults, int>
|
||||
public interface IEnvelopeTypeService : IBasicCRUDService<EnvelopeTypeDefaultsDto, EnvelopeTypeDefaults, int>
|
||||
{
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class MappingProfile : Profile
|
||||
CreateMap<History, HistoryCreateDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen));
|
||||
CreateMap<EnvelopeReceiver, EnvelopeReceiverDto>();
|
||||
CreateMap<EnvelopeReceiver, EnvelopeReceiverSecretDto>();
|
||||
CreateMap<EnvelopeTypeDefaults, EnvelopeTypeDto>();
|
||||
CreateMap<EnvelopeTypeDefaults, EnvelopeTypeDefaultsDto>();
|
||||
CreateMap<Receiver, ReceiverDto>();
|
||||
CreateMap<EnvelopeReceiverReadOnly, EnvelopeReceiverReadOnlyDto>();
|
||||
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<HistoryCreateDto, History>().ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(src => src.ActionDate));
|
||||
CreateMap<EnvelopeReceiverDto, EnvelopeReceiver>();
|
||||
CreateMap<EnvelopeTypeDto, EnvelopeTypeDefaults>();
|
||||
CreateMap<EnvelopeTypeDefaultsDto, EnvelopeTypeDefaults>();
|
||||
CreateMap<ReceiverDto, Receiver>().ForMember(rcv => rcv.EnvelopeReceivers, rcvReadDto => rcvReadDto.Ignore());
|
||||
CreateMap<EnvelopeReceiverReadOnlyCreateDto, EnvelopeReceiverReadOnly>();
|
||||
CreateMap<EnvelopeReceiverReadOnlyUpdateDto, EnvelopeReceiverReadOnly>();
|
||||
|
||||
@@ -9,12 +9,12 @@ namespace EnvelopeGenerator.Application.EnvelopeTypes.Queries;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record ReadEnvelopeTypesQuery : IRequest<IEnumerable<EnvelopeTypeDto>>;
|
||||
public record ReadEnvelopeTypesQuery : IRequest<IEnumerable<EnvelopeTypeDefaultsDto>>;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQuery, IEnumerable<EnvelopeTypeDto>>
|
||||
public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQuery, IEnumerable<EnvelopeTypeDefaultsDto>>
|
||||
{
|
||||
private readonly IRepository<EnvelopeTypeDefaults> _repository;
|
||||
|
||||
@@ -33,13 +33,13 @@ public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQu
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<EnvelopeTypeDto>> Handle(ReadEnvelopeTypesQuery request, CancellationToken cancellationToken)
|
||||
public async Task<IEnumerable<EnvelopeTypeDefaultsDto>> Handle(ReadEnvelopeTypesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// TODO: Temporary manual projection to avoid null-materialization crashes from legacy nullable DB columns in EnvelopeType.
|
||||
// Revisit and switch to AutoMapper query projection (ProjectTo) after schema nullability and mapping contracts are stabilized.
|
||||
return await _repository.Query
|
||||
.AsNoTracking()
|
||||
.Select(t => new EnvelopeTypeDto
|
||||
.Select(t => new EnvelopeTypeDefaultsDto
|
||||
{
|
||||
Id = t.Id,
|
||||
Title = t.Title ?? string.Empty,
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace EnvelopeGenerator.Application.Services;
|
||||
///
|
||||
/// </summary>
|
||||
[Obsolete("Use MediatR")]
|
||||
public class EnvelopeTypeService : BasicCRUDService<IEnvelopeTypeRepository, EnvelopeTypeDto, EnvelopeTypeDefaults, int>, IEnvelopeTypeService
|
||||
public class EnvelopeTypeService : BasicCRUDService<IEnvelopeTypeRepository, EnvelopeTypeDefaultsDto, EnvelopeTypeDefaults, int>, IEnvelopeTypeService
|
||||
{
|
||||
private static readonly Guid CacheKey = Guid.NewGuid();
|
||||
|
||||
@@ -36,8 +36,8 @@ public class EnvelopeTypeService : BasicCRUDService<IEnvelopeTypeRepository, Env
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override async Task<DataResult<IEnumerable<EnvelopeTypeDto>>> ReadAllAsync()
|
||||
public override async Task<DataResult<IEnumerable<EnvelopeTypeDefaultsDto>>> 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.");
|
||||
?? Result.Fail<IEnumerable<EnvelopeTypeDefaultsDto>>().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.");
|
||||
|
||||
}
|
||||
@@ -423,7 +423,7 @@
|
||||
public EventCallback<CreateEnvelopeWizardResult> StartEditorRequested { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public IReadOnlyList<EnvelopeTypeDto> EnvelopeTypes { get; set; } = [];
|
||||
public IReadOnlyList<EnvelopeTypeDefaultsDto> EnvelopeTypes { get; set; } = [];
|
||||
|
||||
private const int TotalSteps = 4;
|
||||
private static readonly System.ComponentModel.DataAnnotations.EmailAddressAttribute EmailValidator = new();
|
||||
@@ -1002,7 +1002,7 @@
|
||||
return bool.TryParse(args.Value?.ToString(), out var parsed) && parsed;
|
||||
}
|
||||
|
||||
private void ApplyEnvelopeTypeDefaults(EnvelopeTypeDto envelopeType)
|
||||
private void ApplyEnvelopeTypeDefaults(EnvelopeTypeDefaultsDto envelopeType)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(envelopeType.Language))
|
||||
_language = envelopeType.Language;
|
||||
|
||||
@@ -698,7 +698,7 @@
|
||||
string _envelopeMessage = string.Empty;
|
||||
bool _titleTouched = false;
|
||||
|
||||
List<EnvelopeTypeDto> _envelopeTypes = [];
|
||||
List<EnvelopeTypeDefaultsDto> _envelopeTypes = [];
|
||||
int? _selectedEnvelopeTypeId;
|
||||
string _language = "de-DE";
|
||||
bool _useAccessCode;
|
||||
@@ -986,7 +986,7 @@
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
void ApplyEnvelopeTypeDefaults(EnvelopeTypeDto envelopeType)
|
||||
void ApplyEnvelopeTypeDefaults(EnvelopeTypeDefaultsDto envelopeType)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(envelopeType.Language))
|
||||
_language = envelopeType.Language;
|
||||
|
||||
@@ -626,7 +626,7 @@
|
||||
private string? _deleteErrorMessage;
|
||||
|
||||
private bool _createWizardVisible = false;
|
||||
private IReadOnlyList<EnvelopeTypeDto> _envelopeTypes = [];
|
||||
private IReadOnlyList<EnvelopeTypeDefaultsDto> _envelopeTypes = [];
|
||||
|
||||
// StableDefaults keys used to store/restore each tab's layout in UserPreferences.GridLayouts
|
||||
private const string GridKeyActive = "sender.active-envelopes";
|
||||
|
||||
@@ -8,7 +8,7 @@ public class EnvelopeTypeService(IHttpClientFactory clientFactory)
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
|
||||
|
||||
public async Task<IReadOnlyList<EnvelopeTypeDto>> GetAsync(CancellationToken cancel = default)
|
||||
public async Task<IReadOnlyList<EnvelopeTypeDefaultsDto>> GetAsync(CancellationToken cancel = default)
|
||||
{
|
||||
var http = clientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||
var response = await http.GetAsync("/api/EnvelopeType", cancel);
|
||||
@@ -16,7 +16,7 @@ public class EnvelopeTypeService(IHttpClientFactory clientFactory)
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return [];
|
||||
|
||||
var data = await response.Content.ReadFromJsonAsync<List<EnvelopeTypeDto>>(JsonOptions, cancel);
|
||||
var data = await response.Content.ReadFromJsonAsync<List<EnvelopeTypeDefaultsDto>>(JsonOptions, cancel);
|
||||
return data ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||
namespace EnvelopeGenerator.Web.Controllers.Test;
|
||||
|
||||
[Obsolete("Use MediatR")]
|
||||
public class TestEnvelopeTypeController : TestControllerBase<IEnvelopeTypeService, EnvelopeTypeDto, EnvelopeTypeDefaults, int>
|
||||
public class TestEnvelopeTypeController : TestControllerBase<IEnvelopeTypeService, EnvelopeTypeDefaultsDto, EnvelopeTypeDefaults, int>
|
||||
{
|
||||
public TestEnvelopeTypeController(ILogger<TestEnvelopeTypeController> logger, IEnvelopeTypeService service) : base(logger, service)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user