Api/NetinaShop.Domain/MapsterRegister.cs

33 lines
1.5 KiB
C#
Raw Normal View History

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();
2024-02-07 01:12:05 +03:30
config.NewConfig<ProductCategory, ProductCategorySDto>()
.Map("ParentName", o => o.Parent != null ? o.Parent.Name : string.Empty)
.TwoWays();
2024-02-07 01:12:05 +03:30
config.NewConfig<Product, ProductSDto>()
.Map("MainImage",o=>o.Files.FirstOrDefault(f=>f.IsPrimary) != null ? o.Files.FirstOrDefault(f => f.IsPrimary).FileLocation : o.Files.Count>0 ? o.Files.FirstOrDefault().FileLocation : string.Empty)
.Map("CategoryName", o => o.Category == null ? null : o.Category.Name)
.Map("BrandName", o => o.Brand == null ? null : o.Brand.Name)
.IgnoreNullValues(false)
.TwoWays();
config.NewConfig<Product, ProductLDto>()
2024-02-08 18:56:56 +03:30
.Map("CategoryName", o => o.Category == null ? null : o.Category.Name)
.Map("BrandName", o => o.Brand == null ? null : o.Brand.Name)
2024-02-07 01:12:05 +03:30
.IgnoreNullValues(false)
.TwoWays();
}
}