From bb29b1563a08ca9e7515a5d07914d7d163ded1c5 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 1 Aug 2025 02:53:52 +0200 Subject: [PATCH] Refactor DTOs and MappingProfile for consistency Standardized namespaces for DTO classes and redefined several records to include necessary properties. Removed mapping configurations from MappingProfile, indicating a potential refactor. Introduced ProfileObjStateDto with a States property and ensured ProfileControlsTFDto and StateDto are properly encapsulated. --- .../DTO/Config/ConfigCreateDto.cs | 4 ---- .../DTO/Config/ConfigUpdateDto.cs | 4 ---- .../ProfileControlsTFCreateDto.cs | 14 -------------- .../ProfileControlsTFUpdateDto.cs | 6 ------ .../ProfileObjState/ProfileObjStateCreateDto.cs | 11 ----------- .../ProfileObjState/ProfileObjStateUpdateDto.cs | 6 ------ .../DTO/State/StateCreateDto.cs | 4 ---- .../DTO/State/StateUpdateDto.cs | 6 ------ .../{DTO/Config => Dto}/ConfigDto.cs | 2 +- .../ProfileControlsTFDto.cs | 2 +- .../ProfileObjStateDto.cs | 2 +- .../{DTO/State => Dto}/StateDto.cs | 2 +- src/WorkFlow.Application/MappingProfile.cs | 16 ---------------- .../DependencyInjection.cs | 11 ++++------- 14 files changed, 8 insertions(+), 82 deletions(-) delete mode 100644 src/WorkFlow.Application/DTO/Config/ConfigCreateDto.cs delete mode 100644 src/WorkFlow.Application/DTO/Config/ConfigUpdateDto.cs delete mode 100644 src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFCreateDto.cs delete mode 100644 src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFUpdateDto.cs delete mode 100644 src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateCreateDto.cs delete mode 100644 src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateUpdateDto.cs delete mode 100644 src/WorkFlow.Application/DTO/State/StateCreateDto.cs delete mode 100644 src/WorkFlow.Application/DTO/State/StateUpdateDto.cs rename src/WorkFlow.Application/{DTO/Config => Dto}/ConfigDto.cs (87%) rename src/WorkFlow.Application/{DTO/ProfileControlsTF => Dto}/ProfileControlsTFDto.cs (94%) rename src/WorkFlow.Application/{DTO/ProfileObjState => Dto}/ProfileObjStateDto.cs (66%) rename src/WorkFlow.Application/{DTO/State => Dto}/StateDto.cs (67%) diff --git a/src/WorkFlow.Application/DTO/Config/ConfigCreateDto.cs b/src/WorkFlow.Application/DTO/Config/ConfigCreateDto.cs deleted file mode 100644 index 3254368..0000000 --- a/src/WorkFlow.Application/DTO/Config/ConfigCreateDto.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace WorkFlow.Application.Dto.Config -{ - public record ConfigCreateDto(string Title, string String); -} \ No newline at end of file diff --git a/src/WorkFlow.Application/DTO/Config/ConfigUpdateDto.cs b/src/WorkFlow.Application/DTO/Config/ConfigUpdateDto.cs deleted file mode 100644 index a3919d0..0000000 --- a/src/WorkFlow.Application/DTO/Config/ConfigUpdateDto.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace WorkFlow.Application.Dto.Config -{ - public record ConfigUpdateDto(string Title, string String) : BaseUpdateDto; -} \ No newline at end of file diff --git a/src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFCreateDto.cs b/src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFCreateDto.cs deleted file mode 100644 index 4bc7803..0000000 --- a/src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFCreateDto.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace WorkFlow.Application.Dto.ProfileControlsTF -{ - public record ProfileControlsTFCreateDto( - int ProfileId, - int UserId, - long ObjId, - string ObjType, - string AttrName, - string CtrlType, - string CtrlCaption, - bool Mandatory, - bool ReadOnly, - string? ChoiceList = null) : BaseCreateDto; -} \ No newline at end of file diff --git a/src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFUpdateDto.cs b/src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFUpdateDto.cs deleted file mode 100644 index 74541a7..0000000 --- a/src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFUpdateDto.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace WorkFlow.Application.Dto.ProfileControlsTF; - -/// -/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates. -/// -public record ProfileControlsTFUpdateDto(long Id); \ No newline at end of file diff --git a/src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateCreateDto.cs b/src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateCreateDto.cs deleted file mode 100644 index 7b883dd..0000000 --- a/src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateCreateDto.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace WorkFlow.Application.Dto.ProfileObjState -{ - public record ProfileObjStateCreateDto( - int ProfileId, - int UserId, - long ObjId, - int StateId, - string? State2 = null, - string? State3 = null, - string? State4 = null) : BaseCreateDto; -} \ No newline at end of file diff --git a/src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateUpdateDto.cs b/src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateUpdateDto.cs deleted file mode 100644 index eae423b..0000000 --- a/src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateUpdateDto.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace WorkFlow.Application.Dto.ProfileObjState; - -/// -/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates. -/// -public record ProfileObjStateUpdateDto(long Id); \ No newline at end of file diff --git a/src/WorkFlow.Application/DTO/State/StateCreateDto.cs b/src/WorkFlow.Application/DTO/State/StateCreateDto.cs deleted file mode 100644 index 3934b16..0000000 --- a/src/WorkFlow.Application/DTO/State/StateCreateDto.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace WorkFlow.Application.Dto.State -{ - public record StateCreateDto(string IntlState) : BaseCreateDto; -} \ No newline at end of file diff --git a/src/WorkFlow.Application/DTO/State/StateUpdateDto.cs b/src/WorkFlow.Application/DTO/State/StateUpdateDto.cs deleted file mode 100644 index b475324..0000000 --- a/src/WorkFlow.Application/DTO/State/StateUpdateDto.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace WorkFlow.Application.Dto.State; - -/// -/// This Data Transfer Object (DTO) serves as a placeholder and does not support updates. -/// -public record StateUpdateDto(int Id); \ No newline at end of file diff --git a/src/WorkFlow.Application/DTO/Config/ConfigDto.cs b/src/WorkFlow.Application/Dto/ConfigDto.cs similarity index 87% rename from src/WorkFlow.Application/DTO/Config/ConfigDto.cs rename to src/WorkFlow.Application/Dto/ConfigDto.cs index 689e78a..6646d82 100644 --- a/src/WorkFlow.Application/DTO/Config/ConfigDto.cs +++ b/src/WorkFlow.Application/Dto/ConfigDto.cs @@ -1,4 +1,4 @@ -namespace WorkFlow.Application.Dto.Config +namespace WorkFlow.Application.Dto { public record ConfigDto(int Id, string Title, diff --git a/src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFDto.cs b/src/WorkFlow.Application/Dto/ProfileControlsTFDto.cs similarity index 94% rename from src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFDto.cs rename to src/WorkFlow.Application/Dto/ProfileControlsTFDto.cs index d431872..9056e3c 100644 --- a/src/WorkFlow.Application/DTO/ProfileControlsTF/ProfileControlsTFDto.cs +++ b/src/WorkFlow.Application/Dto/ProfileControlsTFDto.cs @@ -1,6 +1,6 @@ using DigitalData.UserManager.Application.DTOs.User; -namespace WorkFlow.Application.Dto.ProfileControlsTF +namespace WorkFlow.Application.Dto { public record ProfileControlsTFDto(int Id, int ProfileId, diff --git a/src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateDto.cs b/src/WorkFlow.Application/Dto/ProfileObjStateDto.cs similarity index 66% rename from src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateDto.cs rename to src/WorkFlow.Application/Dto/ProfileObjStateDto.cs index 08b9045..df50988 100644 --- a/src/WorkFlow.Application/DTO/ProfileObjState/ProfileObjStateDto.cs +++ b/src/WorkFlow.Application/Dto/ProfileObjStateDto.cs @@ -1,4 +1,4 @@ -namespace WorkFlow.Application.Dto.ProfileObjState; +namespace WorkFlow.Application.Dto; public class ProfileObjStateDto { diff --git a/src/WorkFlow.Application/DTO/State/StateDto.cs b/src/WorkFlow.Application/Dto/StateDto.cs similarity index 67% rename from src/WorkFlow.Application/DTO/State/StateDto.cs rename to src/WorkFlow.Application/Dto/StateDto.cs index 1bbe132..c6499b0 100644 --- a/src/WorkFlow.Application/DTO/State/StateDto.cs +++ b/src/WorkFlow.Application/Dto/StateDto.cs @@ -1,4 +1,4 @@ -namespace WorkFlow.Application.Dto.State +namespace WorkFlow.Application.Dto { public record StateDto(int Id, string IntlState, string AddedWho, DateTime AddedWhen); } \ No newline at end of file diff --git a/src/WorkFlow.Application/MappingProfile.cs b/src/WorkFlow.Application/MappingProfile.cs index 72d3997..2cde9c9 100644 --- a/src/WorkFlow.Application/MappingProfile.cs +++ b/src/WorkFlow.Application/MappingProfile.cs @@ -1,9 +1,5 @@ using WorkFlow.Application.Buttons; using WorkFlow.Application.Dto; -using WorkFlow.Application.Dto.Config; -using WorkFlow.Application.Dto.ProfileControlsTF; -using WorkFlow.Application.Dto.ProfileObjState; -using WorkFlow.Application.Dto.State; using WorkFlow.Domain.Entities; namespace WorkFlow.Application; @@ -25,17 +21,5 @@ public class MappingProfile : AutoMapper.Profile .ForMember(dest => dest.Sublines, opt => opt.MapFrom(src => new[] { src.Subline1, src.Subline2 })) .ForMember(dest => dest.States, opt => opt.MapFrom(src => src.States)); - - // Mapping create-DTO to entity - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - - // Mapping update-DTO to entity - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); } } \ No newline at end of file diff --git a/src/WorkFlow.Infrastructure/DependencyInjection.cs b/src/WorkFlow.Infrastructure/DependencyInjection.cs index 0b1be95..ed6ed67 100644 --- a/src/WorkFlow.Infrastructure/DependencyInjection.cs +++ b/src/WorkFlow.Infrastructure/DependencyInjection.cs @@ -3,9 +3,6 @@ using DigitalData.Core.Infrastructure.AutoMapper; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using WorkFlow.Application.Contracts.Repositories; -using WorkFlow.Application.Dto.Config; -using WorkFlow.Application.Dto.ProfileControlsTF; -using WorkFlow.Application.Dto.State; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Repositories; @@ -18,11 +15,11 @@ public static class DependencyInjection services.TryAddScoped(); services.TryAddScoped(); - services.AddDbRepository(c => c.Configs).UseAutoMapper(typeof(ConfigUpdateDto)); - services.AddDbRepository(c => c.ProfileControlsTFs).UseAutoMapper(typeof(ProfileControlsTFUpdateDto)); - services.AddDbRepository(c => c.States).UseAutoMapper(typeof(StateUpdateDto)); + services.AddDbRepository(c => c.Configs).UseAutoMapper(); + services.AddDbRepository(c => c.ProfileControlsTFs).UseAutoMapper(); + services.AddDbRepository(c => c.States).UseAutoMapper(); services.AddDbRepository(c => c.Buttons).UseAutoMapper(); - services.AddDbRepository(c => c.States).UseAutoMapper(typeof(StateUpdateDto)); + services.AddDbRepository(c => c.States).UseAutoMapper(); services.AddDbRepository(c => c.ProfileObjStates).UseAutoMapper(); return services;