Refactor DTOs and mappings for improved structure

- Removed `Id`, `Headlines`, and `States` from `ObjectDto`; added `State` property of type `ObjectStateDto?`.
- Completely removed `ProfileControlsTFDto` and `StateDto` classes.
- Removed `Id` from `ProfileDto`, keeping `TypeId` unchanged.
- Updated `MappingProfile` to remove mappings for `ProfileControlsTFDto` and `StateDto`, and changed mapping for `PControlsTF` to `PControlsTFDto`.
- Introduced new `ObjectStateDto` class with properties for `Intl`, `Others`, and a collection of `TFControls`.
- Added new `PControlsTFDto` class with various control attributes.
This commit is contained in:
tekh 2025-08-01 13:19:10 +02:00
parent bc192e99a7
commit 363606dc61
6 changed files with 20 additions and 19 deletions

View File

@ -2,15 +2,11 @@
public class ObjectDto
{
public long? Id { get; set; }
public IEnumerable<string> Headlines { get; set; } = Array.Empty<string>();
public IEnumerable<string> Sublines { get; set; } = Array.Empty<string>();
public string? CmdCheckIn { get; set; }
public IEnumerable<string?> States { get; set; } = Array.Empty<string>();
public IEnumerable<ProfileControlsTFDto> TFControls { get; set; } = Array.Empty<ProfileControlsTFDto>();
public ObjectStateDto? State { get; set; }
}

View File

@ -0,0 +1,13 @@
namespace WorkFlow.Application.Dto;
public record ObjectStateDto
{
public virtual string? Intl { get; set; }
/// <summary>
/// Holds state 2, 3 and 4 as a list of strings.
/// </summary>
public IEnumerable<string> Others { get; set; } = Array.Empty<string>();
public virtual IEnumerable<PControlsTFDto>? TFControls { get; set; }
}

View File

@ -1,9 +1,7 @@
namespace WorkFlow.Application.Dto;
public record ProfileControlsTFDto
public record PControlsTFDto
{
public long Id { get; set; }
public byte? DialogNo { get; set; }
public string? AttrName { get; set; }

View File

@ -4,8 +4,6 @@ namespace WorkFlow.Application.Dto;
public class ProfileDto
{
public int? Id { get; init; }
public byte? TypeId { get; init; }
public string? Caption { get; init; }

View File

@ -1,4 +0,0 @@
namespace WorkFlow.Application.Dto
{
public record StateDto(int Id, string IntlState, string AddedWho, DateTime AddedWhen);
}

View File

@ -11,13 +11,13 @@ public class MappingProfile : AutoMapper.Profile
// Mapping entity to DTO
CreateMap<Config, ConfigDto>();
CreateMap<Profile, ProfileDto>();
CreateMap<PControlsTF, ProfileControlsTFDto>();
CreateMap<State, StateDto>();
CreateMap<PControlsTF, PControlsTFDto>();
CreateMap<Button, ButtonDto>();
CreateMap<PObject, ObjectDto>()
.ForMember(dest => dest.Headlines, opt => opt.MapFrom(src => new[] { src.Headline1, src.Headline2 }))
.ForMember(dest => dest.Sublines, opt => opt.MapFrom(src => new[] { src.Subline1, src.Subline2 }))
.ForMember(dest => dest.States, opt => opt.MapFrom(src => src.State != null ? src.State.ToList() : Array.Empty<string>()))
.ForMember(dest => dest.TFControls, opt => opt.MapFrom(src => src.State != null ? src.State.TFControls : null));
.ForMember(dest => dest.Sublines, opt => opt.MapFrom(src => new[] { src.Subline1, src.Subline2 }));
CreateMap<PObjectState, ObjectStateDto>()
.ForMember(dest => dest.Intl, opt => opt.MapFrom(src => src.State1 != null ? src.State1.IntlState : null))
.ForMember(dest => dest.Others, opt => opt.MapFrom(src => new string?[] { src.State2, src.State3, src.State4 }));
}
}