Files

39 lines
2.3 KiB
C#

using adas_core.Domain.Models.MongoModels;
using adas_core.Infrastructure.Utils.MongoMaps.Interfaz;
using MongoDB.Bson.Serialization;
namespace adas_core.Infrastructure.Utils.MongoMaps;
public class HeaderMapContributor : IEntityMapContributor
{
public void RegisterMaps()
{
if (!BsonClassMap.IsClassMapRegistered(typeof(HeaderConfig)))
BsonClassMap.RegisterClassMap<HeaderConfig>(cm =>
{
cm.AutoMap();
cm.MapMember(c => c.PartnerLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.CompanyLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.CenterLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.MeddisLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.UnitName).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.Cameras).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.Sensors).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.Fullscreen).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.Sounds).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.Sidebar).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
cm.MapMember(c => c.CurrentDateTime).SetDefaultValue(new HeaderConfig.HeaderItem())
.SetIgnoreIfNull(true);
cm.MapMember(c => c.SectionTitle).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
});
if (!BsonClassMap.IsClassMapRegistered(typeof(HeaderConfig.HeaderItem)))
BsonClassMap.RegisterClassMap<HeaderConfig.HeaderItem>(cm =>
{
cm.AutoMap();
cm.MapMember(c => c.LogoUrl).SetDefaultValue(() => null)
.SetIgnoreIfNull(true);
cm.MapMember(c => c.IsVisible).SetDefaultValue(true);
});
}
}