Creado apartir del commit b888de6c92056de294456f581a56e25e734d4ab7 de develop
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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 AuthMapContributor : IEntityMapContributor
|
||||
{
|
||||
public void RegisterMaps()
|
||||
{
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(User)))
|
||||
BsonClassMap.RegisterClassMap<User>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.MapMember(c => c.Password)
|
||||
.SetIgnoreIfNull(true)
|
||||
.SetShouldSerializeMethod(obj => !string.IsNullOrEmpty(((User)obj).Password));
|
||||
cm.MapIdMember(c => c.Id).SetElementName("_id");
|
||||
cm.MapMember(c => c.LockExpirationDate)
|
||||
.SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Authorization).SetElementName("Authorization")
|
||||
.SetShouldSerializeMethod(_ => false);
|
||||
});
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(Authorization)))
|
||||
BsonClassMap.RegisterClassMap<Authorization>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
|
||||
cm.MapIdMember(c => c.Id).SetElementName("_id");
|
||||
cm.MapMember(c => c.UnitId).SetIgnoreIfNull(true);
|
||||
cm.UnmapProperty(c => c.User);
|
||||
cm.UnmapProperty(c => c.Display);
|
||||
cm.UnmapProperty(c => c.Unit);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user