using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PARR.BLL;
using PARR.DAL;
using PARR.EsppSync;
using PARR.EsppScheduleSync.Domain;
using PARR.EsppScheduleSync.Settings;

namespace PARR.EsppScheduleSync
{
    public static class EsppScheduleSyncInstaller
    {
        public static void InstallEsppScheduleSyncServices(this IServiceCollection services, IConfiguration configuration)
        {
            services.InstallBllServices(configuration);
            services.InstallEsppSyncServices<EsppObjectSchedule>(configuration);

            var globalSettings = new GlobalSettings();
            configuration.GetSection(nameof(GlobalSettings)).Bind(globalSettings);
            services.AddSingleton(globalSettings);

            services.AddTransient<IScheduleSyncher, ScheduleSyncher>();
        }

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

            return builder;
        }

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