add custom mapping for Url
This commit is contained in:
parent
cfbd0f013d
commit
bdc773d8ed
@ -1,8 +1,11 @@
|
||||
namespace WorkFlow.Application.Dto;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Web;
|
||||
|
||||
namespace WorkFlow.Application.Dto;
|
||||
|
||||
public class TfFileDto
|
||||
{
|
||||
public string Path { get; set; } = null!;
|
||||
public UriBuilder Url { get; set; } = null!;
|
||||
|
||||
public string? Headline { get; set; }
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using WorkFlow.Application.Buttons;
|
||||
using System.Web;
|
||||
using WorkFlow.Application.Buttons;
|
||||
using WorkFlow.Application.Dto;
|
||||
using WorkFlow.Domain.Entities;
|
||||
|
||||
@ -22,6 +23,18 @@ public class MappingProfile : AutoMapper.Profile
|
||||
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 }));
|
||||
CreateMap<TfFile, TfFileDto>();
|
||||
CreateMap<TfFile, TfFileDto>()
|
||||
.ForMember(dest => dest.Url, opt => opt.MapFrom(src => UriBuilder.WithPath(src.Path, true)));
|
||||
}
|
||||
|
||||
public static UriBuilder UriBuilder { get; set; } = new UriBuilder();
|
||||
}
|
||||
|
||||
internal static class HttpUtilityExtensions
|
||||
{
|
||||
public static UriBuilder WithPath(this UriBuilder builder, string path, bool encode = true)
|
||||
{
|
||||
builder.Path = encode ? HttpUtility.UrlEncode(path) : path;
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user