Add mapping for PObjectStateHist and new DTO record

Introduced a mapping configuration in `MappingProfile` to map `PObjectStateHist` to `ObjectStateHistDto`, including the `Intl` property and an array of `Others`. Added a new record `ObjectStateHistDto` with properties for `Intl`, `Others`, `ChangedWho`, and `ChangedWhen`, initializing `Others` to an empty array of strings.
This commit is contained in:
tekh 2025-08-01 14:00:26 +02:00
parent 7d07fc58e9
commit f10f5af541
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,15 @@
namespace WorkFlow.Application.Dto;
public record ObjectStateHistDto
{
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 string? ChangedWho { get; set; }
public DateTime? ChangedWhen { get; set; }
}

View File

@ -19,5 +19,8 @@ public class MappingProfile : AutoMapper.Profile
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 }));
CreateMap<PObjectStateHist, ObjectStateHistDto>()
.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 }));
}
}