using Mapster;
using MapsterMapper;
using Microsoft.Extensions.DependencyInjection;
using NexusReader.Domain.Entities;
using NexusReader.Application.DTOs.User;

namespace NexusReader.Application.Mappings;

public static class MappingConfig
{
    public static IServiceCollection AddMapsterConfiguration(this IServiceCollection services)
    {
        var config = TypeAdapterConfig.GlobalSettings;
        
        config.NewConfig<NexusUser, UserProfileDto>();
        config.NewConfig<Ebook, LastReadBookDto>()
            .Map(dest => dest.Description, src => src.Description);

        services.AddSingleton(config);
        services.AddScoped<IMapper, ServiceMapper>();

        return services;
    }
}

