Added auto mapper profiles

This commit is contained in:
Cristiano
2025-11-06 17:17:04 +01:00
parent 6bc8281a37
commit 76e48493f4
4 changed files with 132 additions and 1 deletions
+16
View File
@@ -1,7 +1,11 @@
using AutoMapper;
using AutoMapper.EquivalencyExpression;
using PyroFetes;
using FastEndpoints;
using FastEndpoints.Swagger;
using FastEndpoints.Security;
using PyroFetes.MappingProfiles;
using IMapper = FastEndpoints.IMapper;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
@@ -15,6 +19,18 @@ builder.Services
// On ajoute ici la configuration de la base de données
builder.Services.AddDbContext<PyroFetesDbContext>();
MapperConfiguration mappingConfig = new(mc =>
{
mc.AddCollectionMappers();
mc.AddProfile(new DtoToEntityMappings());
mc.AddProfile(new EntityToDtoMappings());
}, new LoggerFactory());
AutoMapper.IMapper mapper = mappingConfig.CreateMapper();
builder.Services.AddSingleton(mapper);
// On construit l'application en lui donnant vie
WebApplication app = builder.Build();
app.UseAuthentication()