Added auto mapper profiles
This commit is contained in:
68
PyroFetes/MappingProfiles/DtoToEntityMappings.cs
Normal file
68
PyroFetes/MappingProfiles/DtoToEntityMappings.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using PyroFetes.DTO.Deliverer.Request;
|
||||||
|
using PyroFetes.DTO.DeliveryNote.Request;
|
||||||
|
using PyroFetes.DTO.Price.Request;
|
||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.ProductDelivery.Request;
|
||||||
|
using PyroFetes.DTO.PurchaseOrder.Request;
|
||||||
|
using PyroFetes.DTO.PurchaseProduct.Request;
|
||||||
|
using PyroFetes.DTO.Quotation.Request;
|
||||||
|
using PyroFetes.DTO.QuotationProduct.Request;
|
||||||
|
using PyroFetes.DTO.SettingDTO.Request;
|
||||||
|
using PyroFetes.DTO.Supplier.Request;
|
||||||
|
using PyroFetes.DTO.User.Request;
|
||||||
|
using PyroFetes.DTO.WareHouseProduct.Request;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.MappingProfiles;
|
||||||
|
|
||||||
|
public class DtoToEntityMappings : Profile
|
||||||
|
{
|
||||||
|
public DtoToEntityMappings()
|
||||||
|
{
|
||||||
|
CreateMap<CreateDelivererDto, Deliverer>();
|
||||||
|
CreateMap<UpdateDelivererDto, Deliverer>();
|
||||||
|
|
||||||
|
CreateMap<CreateDeliveryNoteDto, DeliveryNote>();
|
||||||
|
CreateMap<UpdateDeliveryNoteDto, DeliveryNote>();
|
||||||
|
CreateMap<PatchDeliveryNoteRealDeliveryDateDto, DeliveryNote>();
|
||||||
|
|
||||||
|
CreateMap<CreatePriceDto, Price>();
|
||||||
|
CreateMap<UpdatePriceDto, Price>();
|
||||||
|
CreateMap<PatchPriceSellingPriceDto, Price>();
|
||||||
|
|
||||||
|
CreateMap<CreateProductDto, Product>();
|
||||||
|
CreateMap<UpdateProductDto, Product>();
|
||||||
|
CreateMap<PatchProductMinimalStockDto, Product>();
|
||||||
|
|
||||||
|
CreateMap<CreateProductDeliveryDto, ProductDelivery>();
|
||||||
|
CreateMap<UpdateProductDeliveryDto, ProductDelivery>();
|
||||||
|
|
||||||
|
CreateMap<PatchPurchaseOrderPurchaseConditionsDto,PurchaseOrder>();
|
||||||
|
|
||||||
|
CreateMap<CreatePurchaseProductDto, PurchaseProduct>();
|
||||||
|
CreateMap<UpdatePurchaseProductDto, PurchaseProduct>();
|
||||||
|
CreateMap<PatchPurchaseProductQuantityDto, PurchaseProduct>();
|
||||||
|
|
||||||
|
CreateMap<PatchQuotationConditionsSaleDto, Quotation>();
|
||||||
|
CreateMap<PatchQuotationMessageDto, Quotation>();
|
||||||
|
|
||||||
|
CreateMap<CreateQuotationProductDto, QuotationProduct>();
|
||||||
|
CreateMap<UpdateQuotationProductDto, QuotationProduct>();
|
||||||
|
CreateMap<PatchQuotationProductQuantityDto, QuotationProduct>();
|
||||||
|
|
||||||
|
CreateMap<CreateSettingDto, Setting>();
|
||||||
|
CreateMap<PatchSettingElectronicSignatureDto, Setting>();
|
||||||
|
CreateMap<PatchSettingLogoDto, Setting>();
|
||||||
|
|
||||||
|
CreateMap<CreateSupplierDto, Supplier>();
|
||||||
|
CreateMap<UpdateSupplierDto, Supplier>();
|
||||||
|
CreateMap<PatchSupplierDeliveryDelayDto, Supplier>();
|
||||||
|
|
||||||
|
CreateMap<CreateUserDto, User>();
|
||||||
|
CreateMap<UpdateUserDto, User>();
|
||||||
|
CreateMap<PatchUserPasswordDto, User>();
|
||||||
|
|
||||||
|
CreateMap<PatchWareHouseProductQuantityDto, WarehouseProduct>();
|
||||||
|
}
|
||||||
|
}
|
||||||
46
PyroFetes/MappingProfiles/EntityToDtoMappings.cs
Normal file
46
PyroFetes/MappingProfiles/EntityToDtoMappings.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using PyroFetes.DTO.Deliverer.Response;
|
||||||
|
using PyroFetes.DTO.DeliveryNote.Response;
|
||||||
|
using PyroFetes.DTO.Price.Response;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.DTO.ProductDelivery.Response;
|
||||||
|
using PyroFetes.DTO.PurchaseOrder.Response;
|
||||||
|
using PyroFetes.DTO.PurchaseProduct.Response;
|
||||||
|
using PyroFetes.DTO.Quotation.Response;
|
||||||
|
using PyroFetes.DTO.QuotationProduct.Response;
|
||||||
|
using PyroFetes.DTO.SettingDTO.Response;
|
||||||
|
using PyroFetes.DTO.User.Response;
|
||||||
|
using PyroFetes.DTO.WareHouseProduct.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.MappingProfiles;
|
||||||
|
|
||||||
|
public class EntityToDtoMappings : Profile
|
||||||
|
{
|
||||||
|
public EntityToDtoMappings()
|
||||||
|
{
|
||||||
|
CreateMap<Deliverer, GetDelivererDto>();
|
||||||
|
|
||||||
|
CreateMap<DeliveryNote, GetDeliveryNoteDto>();
|
||||||
|
|
||||||
|
CreateMap<Price, GetPriceDto>();
|
||||||
|
|
||||||
|
CreateMap<Product, GetProductDto>();
|
||||||
|
|
||||||
|
CreateMap<ProductDelivery, GetProductDeliveryDto>();
|
||||||
|
|
||||||
|
CreateMap<PurchaseOrder, GetPurchaseOrderDto>();
|
||||||
|
|
||||||
|
CreateMap<PurchaseProduct, GetPurchaseProductDto>();
|
||||||
|
|
||||||
|
CreateMap<Quotation, GetQuotationDto>();
|
||||||
|
|
||||||
|
CreateMap<QuotationProduct, GetQuotationProductDto>();
|
||||||
|
|
||||||
|
CreateMap<Setting, GetSettingDto>();
|
||||||
|
|
||||||
|
CreateMap<User, GetUserDto>();
|
||||||
|
|
||||||
|
CreateMap<WarehouseProduct, GetWareHouseProductDto>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using AutoMapper.EquivalencyExpression;
|
||||||
using PyroFetes;
|
using PyroFetes;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using FastEndpoints.Swagger;
|
using FastEndpoints.Swagger;
|
||||||
using FastEndpoints.Security;
|
using FastEndpoints.Security;
|
||||||
|
using PyroFetes.MappingProfiles;
|
||||||
|
using IMapper = FastEndpoints.IMapper;
|
||||||
|
|
||||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -15,6 +19,18 @@ builder.Services
|
|||||||
// On ajoute ici la configuration de la base de données
|
// On ajoute ici la configuration de la base de données
|
||||||
builder.Services.AddDbContext<PyroFetesDbContext>();
|
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
|
// On construit l'application en lui donnant vie
|
||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
app.UseAuthentication()
|
app.UseAuthentication()
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="15.1.0" />
|
<PackageReference Include="AutoMapper" Version="15.0.1" />
|
||||||
|
<PackageReference Include="AutoMapper.Collection" Version="11.0.0" />
|
||||||
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
|
||||||
<PackageReference Include="FastEndpoints" Version="7.0.1" />
|
<PackageReference Include="FastEndpoints" Version="7.0.1" />
|
||||||
<PackageReference Include="FastEndpoints.Security" Version="7.0.1" />
|
<PackageReference Include="FastEndpoints.Security" Version="7.0.1" />
|
||||||
|
|||||||
Reference in New Issue
Block a user