Merged AutoMapper branch

This commit is contained in:
Cristiano
2025-11-13 14:44:28 +01:00
parent 6bc8281a37
commit 9684dbcbc7
9 changed files with 477 additions and 23 deletions

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()