Browse Source

fix: fixed dto mapping field.

pull/615/head
cKey 4 years ago
parent
commit
35e9cc7033
  1. 35
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhooksManagementApplicationMapperProfile.cs

35
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhooksManagementApplicationMapperProfile.cs

@ -1,4 +1,7 @@
using AutoMapper;
using System.Collections.Generic;
using System;
using Newtonsoft.Json;
namespace LINGYUN.Abp.WebhooksManagement;
@ -7,6 +10,36 @@ public class WebhooksManagementApplicationMapperProfile : Profile
public WebhooksManagementApplicationMapperProfile()
{
CreateMap<WebhookEventRecord, WebhookEventRecordDto>();
CreateMap<WebhookSendRecord, WebhookSendRecordDto>();
CreateMap<WebhookSendRecord, WebhookSendRecordDto>()
.ForMember(dto => dto.RequestHeaders, map => map.MapFrom((src, dto) =>
{
var result = new Dictionary<string, string>();
if (src.RequestHeaders.IsNullOrWhiteSpace())
{
try
{
result = JsonConvert.DeserializeObject< Dictionary<string, string>>(src.RequestHeaders);
}
catch { }
}
return result;
}))
.ForMember(dto => dto.ResponseHeaders, map => map.MapFrom((src, dto) =>
{
var result = new Dictionary<string, string>();
if (src.ResponseHeaders.IsNullOrWhiteSpace())
{
try
{
result = JsonConvert.DeserializeObject<Dictionary<string, string>>(src.ResponseHeaders);
}
catch { }
}
return result;
}));
}
}

Loading…
Cancel
Save