using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace skydiveLogs_api.Ioc
{
    public class IocService
    {
        public IocService(IServiceCollection services,
                          IConfiguration configuration)
        {
            _services = services;
            _configuration = configuration;
        }

        public void Configure()
        {
            //services.AddSingleton<IConfigurationRoot>(Configuration);
            //_services.AddSingleton<Services.IGroupService, Services.GroupService>();
            //_services.AddSingleton<Services.IUserService, Services.UserService>();
            //_services.AddSingleton<Services.IPermissionService, Services.PermissionService>();

            _services.AddScoped<Business.Interface.IAircraftService, Business.AircraftService>();
            _services.AddScoped<Business.Interface.IGearService, Business.GearService>();
            _services.AddScoped<Business.Interface.IDropZoneService, Business.DropZoneService>();
            _services.AddScoped<Business.Interface.IJumpService, Business.JumpService>();
            _services.AddScoped<Business.Interface.IJumpTypeService, Business.JumpTypeService>();
            _services.AddScoped<Business.Interface.IStatsService, Business.StatsService>();
            _services.AddScoped<Business.Interface.IUserService, Business.UserService>();

            _services.AddScoped<Data.Interface.IAircraftRepository, Data.AircraftRepository>();
            _services.AddScoped<Data.Interface.IDropZoneRepository, Data.DropZoneRepository>();
            _services.AddScoped<Data.Interface.IJumpRepository, Data.JumpRepository>();
            _services.AddScoped<Data.Interface.IJumpTypeRepository, Data.JumpTypeRepository>();
            _services.AddScoped<Data.Interface.IGearRepository, Data.GearRepository>();
            _services.AddScoped<Data.Interface.IUserRepository, Data.UserRepository>();

            string connectionString = _configuration.GetConnectionString("DefaultConnection");
            _services.AddSingleton<Data.Interface.IDataProvider>(c => new Data.LiteDbProvider(connectionString));
        }

        private readonly IServiceCollection _services;

        private readonly IConfiguration _configuration;
    }
}
