using BarBusinessLogic.BusinessLogics;
using BarBusinessLogic.OfficePackage.Implements;
using BarBusinessLogic.OfficePackage;
using BarContracts.BusinessLogicContracts;
using BarContracts.StoragesContracts;
using BarDatabaseImplement.Implements;
using BarView.Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;


namespace BarView
{
    internal static class Program
    {
        private static ServiceProvider? _serviceProvider;
        public static ServiceProvider? ServiceProvider => _serviceProvider;

        [STAThread]
        static void Main()
        {
            ApplicationConfiguration.Initialize();

            var Services = new ServiceCollection();
            ConfigureServices(Services);

            _serviceProvider = Services.BuildServiceProvider();
            Application.Run(_serviceProvider.GetRequiredService<FormMain>());
        }

        private static void ConfigureServices(ServiceCollection Services)
        {
            Services.AddLogging(option =>
            {
                option.SetMinimumLevel(LogLevel.Information);
                option.AddNLog("nlog.config");
            });

            Services.AddTransient<IComponentStorage, ComponentStorage>();
            Services.AddTransient<IOrderStorage, OrderStorage>();
            Services.AddTransient<ICocktailStorage, CocktailStorage>();

            Services.AddTransient<IComponentLogic, ComponentLogic>();
            Services.AddTransient<IOrderLogic, OrderLogic>();
            Services.AddTransient<ICocktailLogic, CocktailLogic>();
            Services.AddTransient<IReportLogic, ReportLogic>();
            Services.AddTransient<IClientLogic, ClientLogic>();
            Services.AddTransient<IClientStorage, ClientStorage>();

            Services.AddTransient<AbstractSaveToWord, SaveToWord>();
            Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
            Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();

            Services.AddTransient<FormMain>();
            Services.AddTransient<FormComponent>();
            Services.AddTransient<FormComponents>();
            Services.AddTransient<FormCreateOrder>();
            Services.AddTransient<FormCocktail>();
            Services.AddTransient<FormCocktailComponent>();
            Services.AddTransient<FormCocktails>();
            Services.AddTransient<FormReportCocktailComponents>();
            Services.AddTransient<FormReportOrders>();
            Services.AddTransient<FormClients>();
        }
    }
}