From d46fa606b7e2740074b139c0e2bcd4b3fd864d2c Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Mon, 25 May 2026 12:19:05 +0100 Subject: [PATCH] Fixed error with creation of document --- ...eateQuotationProductDto.cs => AddQuotationProductDto.cs} | 0 PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs | 3 +-- PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs | 6 +++--- PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs | 1 - PyroFetes/MappingProfiles/DtoToEntityMappings.cs | 6 +++++- 5 files changed, 9 insertions(+), 7 deletions(-) rename PyroFetes/DTO/QuotationProduct/Request/{CreateQuotationProductDto.cs => AddQuotationProductDto.cs} (100%) diff --git a/PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs b/PyroFetes/DTO/QuotationProduct/Request/AddQuotationProductDto.cs similarity index 100% rename from PyroFetes/DTO/QuotationProduct/Request/CreateQuotationProductDto.cs rename to PyroFetes/DTO/QuotationProduct/Request/AddQuotationProductDto.cs diff --git a/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs b/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs index 0e5406c7..6428158e 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/CreatePurchaseOrder.cs @@ -23,6 +23,7 @@ public class CreatePurchaseOrder( public override async Task HandleAsync(CreatePurchaseOrderDto req, CancellationToken ct) { PurchaseOrder purchaseOrder = mapper.Map(req); + await purchaseOrdersRepository.AddAsync(purchaseOrder, ct); if (req.Products != null) { @@ -49,8 +50,6 @@ public class CreatePurchaseOrder( await purchaseProductsRepository.AddAsync(productOnPurchase, ct); } } - - await purchaseOrdersRepository.AddAsync(purchaseOrder, ct); await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs index 1ec4e1f1..f8b2f9a2 100644 --- a/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/CreateQuotationEndpoint.cs @@ -1,6 +1,5 @@ using FastEndpoints; using PyroFetes.DTO.Quotation.Request; -using PyroFetes.DTO.Quotation.Response; using PyroFetes.DTO.QuotationProduct.Request; using PyroFetes.Models; using PyroFetes.Repositories; @@ -25,6 +24,7 @@ public class CreateQuotationEndpoint( { Quotation quotation = mapper.Map(req); quotation.CustomerId = 1; // TODO: A changer + await quotationsRepository.AddAsync(quotation, ct); if (req.Products != null) { @@ -43,6 +43,7 @@ public class CreateQuotationEndpoint( if (quotationProduct is not null) { await Send.StringAsync("Le produit est déjà dans le devis", 400, cancellation: ct); + return; } QuotationProduct? productOnQuotation = mapper.Map(line); @@ -51,8 +52,7 @@ public class CreateQuotationEndpoint( await quotationProductsRepository.AddAsync(productOnQuotation, ct); } } - - await quotationsRepository.AddAsync(quotation, ct); + await Send.NoContentAsync(ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs index 703c69cd..4284b5d3 100644 --- a/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/UpdateQuotationEndpoint.cs @@ -1,6 +1,5 @@ using FastEndpoints; using PyroFetes.DTO.Quotation.Request; -using PyroFetes.DTO.Quotation.Response; using PyroFetes.Models; using PyroFetes.Repositories; using PyroFetes.Specifications.Quotations; diff --git a/PyroFetes/MappingProfiles/DtoToEntityMappings.cs b/PyroFetes/MappingProfiles/DtoToEntityMappings.cs index 152d0c3e..5b7d8b74 100644 --- a/PyroFetes/MappingProfiles/DtoToEntityMappings.cs +++ b/PyroFetes/MappingProfiles/DtoToEntityMappings.cs @@ -44,6 +44,7 @@ public class DtoToEntityMappings : Profile .ForMember(dest => dest.Id, opt => opt.Ignore()); CreateMap(); + CreateMap(); CreateMap() .ForMember(dest => dest.ProductId, opt => opt.Ignore()) .ForMember(dest => dest.PurchaseOrderId, opt => opt.Ignore()); @@ -52,7 +53,10 @@ public class DtoToEntityMappings : Profile .ForMember(dest => dest.Id, opt => opt.Ignore()); CreateMap() .ForMember(dest => dest.Id, opt => opt.Ignore()); - CreateMap(); + CreateMap(); + CreateMap(); + CreateMap() + .ForMember(dest => dest.Id, opt => opt.Ignore()); CreateMap(); CreateMap()