using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PARR.BLL;
using PARR.DAL;
using PARR.JobAutoControl.Settings;

namespace PARR.JobAutoControl
{
    public static class JobAutoControlInstaller
    {

        public static void InstallJobAutoControlServices(this IServiceCollection services, IConfiguration configuration)
        {
            services.InstallDalServices(configuration);
            services.InstallBllServices(configuration);

            var settings = new WorkerSettings();
            configuration.GetSection(nameof(WorkerSettings)).Bind(settings);
            services.AddSingleton(settings);

            var mqSettings = new MqSettings();
            configuration.GetSection(nameof(MqSettings)).Bind(mqSettings);
            services.AddSingleton(mqSettings);


            services.AddTransient<IJobAutoControlManager, JobAutoControlManager>();
        }


        public static IConfigurationBuilder AddJobAutoControlConfigurations(this IConfigurationBuilder builder, IServiceCollection services)
        {
            builder.AddDalConfigurations(services);

            return builder;
        }


        public static void AddJobAutoControlSettings(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddDallSettings(configuration);
        }

    }
}
