Compare commits

..

4 Commits

Author SHA1 Message Date
6288312c01 feat(ObjectStateDto): add TfFiles property 2025-08-03 12:29:57 +02:00
91679180ec feat(UriBuilderResolver): add to be able to dependencies.
- add UriBuilderFactory confoguration
 - inejct UriBuilderResolver as transient
2025-08-03 12:25:39 +02:00
bdc773d8ed add custom mapping for Url 2025-08-03 11:33:42 +02:00
cfbd0f013d fix property naming 2025-08-03 09:56:42 +02:00
6 changed files with 42 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using WorkFlow.Application.Mapping;
namespace WorkFlow.Application; namespace WorkFlow.Application;
@@ -16,11 +17,16 @@ public static class DependencyInjection
cfg.LicenseKey = diOptions.MediatRLicense; cfg.LicenseKey = diOptions.MediatRLicense;
}); });
services.AddSingleton(diOptions.UriBuilderFactory());
services.AddTransient<UriBuilderResolver>();
return services; return services;
} }
public class WorkFlowServiceOptions public class WorkFlowServiceOptions
{ {
public string MediatRLicense { get; set; } = string.Empty; public string MediatRLicense { get; set; } = string.Empty;
public Func<UriBuilder> UriBuilderFactory { get; set; } = () => new UriBuilder();
} }
} }

View File

@@ -10,4 +10,6 @@ public record ObjectStateDto
public IEnumerable<string> Others { get; set; } = Array.Empty<string>(); public IEnumerable<string> Others { get; set; } = Array.Empty<string>();
public virtual IEnumerable<PControlsTFDto>? TFControls { get; set; } public virtual IEnumerable<PControlsTFDto>? TFControls { get; set; }
public virtual IEnumerable<TfFileDto>? TfFiles { get; set; }
} }

View File

@@ -2,7 +2,7 @@
public class TfFileDto public class TfFileDto
{ {
public string FFapth { get; set; } = null!; public UriBuilder Url { get; set; } = null!;
public string? Headline { get; set; } public string? Headline { get; set; }

View File

@@ -2,26 +2,33 @@
using WorkFlow.Application.Dto; using WorkFlow.Application.Dto;
using WorkFlow.Domain.Entities; using WorkFlow.Domain.Entities;
namespace WorkFlow.Application; namespace WorkFlow.Application.Mapping;
public class MappingProfile : AutoMapper.Profile public class MappingProfile : AutoMapper.Profile
{ {
public MappingProfile() public MappingProfile()
{ {
// Mapping entity to DTO
CreateMap<Config, ConfigDto>(); CreateMap<Config, ConfigDto>();
CreateMap<Profile, ProfileDto>(); CreateMap<Profile, ProfileDto>();
CreateMap<PControlsTF, PControlsTFDto>(); CreateMap<PControlsTF, PControlsTFDto>();
CreateMap<Button, ButtonDto>(); CreateMap<Button, ButtonDto>();
CreateMap<PObject, ObjectDto>() CreateMap<PObject, ObjectDto>()
.ForMember(dest => dest.Headlines, opt => opt.MapFrom(src => new[] { src.Headline1, src.Headline2 })) .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.Sublines, opt => opt.MapFrom(src => new[] { src.Subline1, src.Subline2 }));
CreateMap<PObjectState, ObjectStateDto>() CreateMap<PObjectState, ObjectStateDto>()
.ForMember(dest => dest.Intl, opt => opt.MapFrom(src => src.State1 != null ? src.State1.IntlState : null)) .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 })); .ForMember(dest => dest.Others, opt => opt.MapFrom(src => new string?[] { src.State2, src.State3, src.State4 }));
CreateMap<PObjectStateHist, ObjectStateHistDto>() CreateMap<PObjectStateHist, ObjectStateHistDto>()
.ForMember(dest => dest.Intl, opt => opt.MapFrom(src => src.State1 != null ? src.State1.IntlState : null)) .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 })); .ForMember(dest => dest.Others, opt => opt.MapFrom(src => new string?[] { src.State2, src.State3, src.State4 }));
CreateMap<TfFile, TfFileDto>();
CreateMap<TfFile, TfFileDto>()
.ForMember(dest => dest.Url, opt => opt.MapFrom<UriBuilderResolver>());
} }
} }

View File

@@ -0,0 +1,22 @@
using AutoMapper;
using System.Web;
using WorkFlow.Application.Dto;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Application.Mapping;
public class UriBuilderResolver : IValueResolver<TfFile, TfFileDto, UriBuilder>
{
private readonly UriBuilder _uriBuilder;
public UriBuilderResolver(UriBuilder uriBuilder) => _uriBuilder = uriBuilder;
public UriBuilder Resolve(TfFile source, TfFileDto destination, UriBuilder destMember, ResolutionContext context)
{
var builder = new UriBuilder(_uriBuilder.Uri)
{
Path = HttpUtility.UrlEncode(source.Path)
};
return builder;
}
}

View File

@@ -17,7 +17,7 @@ public class TfFile
[Required] [Required]
[StringLength(512)] [StringLength(512)]
[Column("F_FAPTH", TypeName = "nvarchar(512)")] [Column("F_FAPTH", TypeName = "nvarchar(512)")]
public string FFapth { get; set; } = null!; public string Path { get; set; } = null!;
/// <summary> /// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow /// Although this field is marked as <c>nullable</c> in the database schema to allow