using adas_core.Domain.Models;
using adas_core.Domain.Models.Recording;
using adas_core.Domain.Models.SignalR;
using adas_core.Domain.Models.SystemAlerts;
using adas_core.Infrastructure.Utils.MongoMaps.Interfaz;
using MongoDB.Bson.Serialization;

namespace adas_core.Infrastructure.Utils.MongoMaps;

public class ComunicationFlowMapContributor : IEntityMapContributor
{
    public void RegisterMaps()
    {
        if (!BsonClassMap.IsClassMapRegistered(typeof(Message)))
            BsonClassMap.RegisterClassMap<Message>(cm =>
            {
                cm.AutoMap();
                cm.UnmapMember(c => c.Operation);
            });

        if (!BsonClassMap.IsClassMapRegistered(typeof(Queue)))
            BsonClassMap.RegisterClassMap<Queue>(cm => { cm.AutoMap(); });

        if (!BsonClassMap.IsClassMapRegistered(typeof(ApiRequest)))
            BsonClassMap.RegisterClassMap<ApiRequest>(cm => { cm.AutoMap(); });

        if (!BsonClassMap.IsClassMapRegistered(typeof(AdmPanelRequest)))
            BsonClassMap.RegisterClassMap<AdmPanelRequest>(cm =>
            {
                cm.AutoMap();
                cm.GetMemberMap(c => c.ObsertationData).SetIgnoreIfNull(true);
            });

        if (!BsonClassMap.IsClassMapRegistered(typeof(ApiClients)))
            BsonClassMap.RegisterClassMap<ApiClients>(cm => { cm.AutoMap(); });

        if (!BsonClassMap.IsClassMapRegistered(typeof(VideoDto)))
            BsonClassMap.RegisterClassMap<VideoDto>(cm => { cm.AutoMap(); });
    }
}