Compare commits
4 Commits
d4b33d4b9a
...
6288312c01
| Author | SHA1 | Date | |
|---|---|---|---|
| 6288312c01 | |||
| 91679180ec | |||
| bdc773d8ed | |||
| cfbd0f013d |
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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; }
|
||||||
}
|
}
|
||||||
@@ -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; }
|
||||||
|
|
||||||
|
|||||||
@@ -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>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
22
src/WorkFlow.Application/Mapping/UriBuilderResolver.cs
Normal file
22
src/WorkFlow.Application/Mapping/UriBuilderResolver.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user