26 lines
1.0 KiB
C#
26 lines
1.0 KiB
C#
namespace NetinaShop.Domain;
|
|
|
|
public class MapsterRegister : IRegister
|
|
{
|
|
public void Register(TypeAdapterConfig config)
|
|
{
|
|
config.NewConfig<Blog, BlogSDto>()
|
|
.Map("HeaderFileName", o => o.Files.Count > 0 && o.Files.Any(f=>f.IsHeader) ? o.Files.FirstOrDefault(f=>f.IsHeader)!.FileName : string.Empty)
|
|
.TwoWays();
|
|
|
|
config.NewConfig<Brand, BrandSDto>()
|
|
.Map("HeaderFileName", o => o.Files.Count > 0 && o.Files.Any(f => f.IsHeader) ? o.Files.FirstOrDefault(f => f.IsHeader)!.FileName : string.Empty)
|
|
.TwoWays();
|
|
|
|
config.NewConfig<ProductCategory, ProductCategorySDto>()
|
|
.Map("ParentName", o => o.Parent != null ? o.Parent.Name : string.Empty)
|
|
.TwoWays();
|
|
|
|
config.NewConfig<Product, ProductSDto>()
|
|
.Map("CategoryName", o => o.Category == null ? null : o.Category.Name)
|
|
.Map("BrandName", o => o.Brand == null ? null : o.Brand.Name)
|
|
.IgnoreNullValues(false)
|
|
.TwoWays();
|
|
|
|
}
|
|
} |