using e_suite.Messaging.Common.models;
using Microsoft.Extensions.Configuration;

namespace e_suite.Messaging.Common;

public class DatabaseMessageSender : MessageSenderBase, IDatabaseMessageSender
{
    public DatabaseMessageSender(IConfiguration configuration, IRabbitMqConnectionFactory connectionFactory) : base(configuration, connectionFactory, MessageQueueNames.Database)
    {

    }

    public void PostClearOldSentinelData()
    {
        var maintenanceMessage = new DatabaseMessage
        {
            MessageType = DatabaseMessageTypes.ClearOldSentinelData
        };

        Task.Run(async () =>
        {
            await PostMessage(maintenanceMessage);
        }).Wait();
    }

    public void PostClearOldPerformanceData()
    {
        var maintenanceMessage = new DatabaseMessage
        {
            MessageType = DatabaseMessageTypes.ClearOldPerformanceData
        };

        Task.Run(async () =>
        {
            await PostMessage(maintenanceMessage);
        }).Wait();
    }

    public void PostClearOldEmailActions()
    {
        var maintenanceMessage = new DatabaseMessage
        {
            MessageType = DatabaseMessageTypes.ClearOldEmailActions
        };

        Task.Run(async () =>
        {
            await PostMessage(maintenanceMessage);
        }).Wait();
    }

    public void PostClearOldSingleUserGuids()
    {
        var maintenanceMessage = new DatabaseMessage
        {
            MessageType = DatabaseMessageTypes.ClearOldSingleUserGuids
        };

        Task.Run(async () =>
        {
            await PostMessage(maintenanceMessage);
        }).Wait();
    }
}