mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
826 B
24 lines
826 B
namespace Volo.Abp.MultiLingualObjects;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using global::AutoMapper;
|
|
using Volo.Abp.MultiLingualObjects.TestObjects;
|
|
|
|
public class MultiLingualObjectTestProfile : Profile
|
|
{
|
|
public MultiLingualObjectTestProfile()
|
|
{
|
|
CreateMap<MultiLingualBook, MultiLingualBookDto>()
|
|
.ForMember(x => x.Name,
|
|
x => x.MapFrom((src, target, member, context) =>
|
|
{
|
|
if (context.Items.TryGetValue(nameof(MultiLingualBookTranslation), out var translationsRaw) && translationsRaw is IReadOnlyDictionary<Guid, MultiLingualBookTranslation> translations)
|
|
{
|
|
return translations.GetValueOrDefault(src.Id)?.Name;
|
|
}
|
|
return null;
|
|
}));
|
|
}
|
|
}
|