using CalledIt.DataAccess;
using CalledIt.Util;
using FluentValidation;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CalledIt.Domain;

public class DomainModule : DependencyInjectionModule
{
    protected override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
    {
        services.RegisterModule<DataAccessModule>(configuration);
        services.AddValidatorsFromAssemblyContaining<DomainModule>();
        services.AddScoped<Services.IPasswordService, Services.PasswordService>();
        services.AddScoped<Services.IUserService, Services.UserService>();
        services.AddScoped<Services.ICompetitionService, Services.CompetitionService>();
        services.AddScoped<Services.ITeamService, Services.TeamService>();
        services.AddScoped<Services.IMatchService, Services.MatchService>();
        services.AddScoped<Services.IBetService, Services.BetService>();
        services.AddScoped<Services.ILeaderboardService, Services.LeaderboardService>();
        services.AddSingleton<Services.TokenRevocationService>();
        services.AddSingleton<Services.ITokenRevocationService>(sp =>
            sp.GetRequiredService<Services.TokenRevocationService>());
        services.AddScoped<Services.IGroupService, Services.GroupService>();
        services.AddScoped<Services.IRefreshTokenService, Services.RefreshTokenService>();
        services.Configure<UploadOptions>(configuration.GetSection(UploadOptions.SectionName));
    }
}
