Fixed error with creation of document
This commit is contained in:
@@ -23,6 +23,7 @@ public class CreatePurchaseOrder(
|
||||
public override async Task HandleAsync(CreatePurchaseOrderDto req, CancellationToken ct)
|
||||
{
|
||||
PurchaseOrder purchaseOrder = mapper.Map<PurchaseOrder>(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);
|
||||
}
|
||||
}
|
||||
@@ -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<Quotation>(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<QuotationProduct>(line);
|
||||
@@ -51,8 +52,7 @@ public class CreateQuotationEndpoint(
|
||||
await quotationProductsRepository.AddAsync(productOnQuotation, ct);
|
||||
}
|
||||
}
|
||||
|
||||
await quotationsRepository.AddAsync(quotation, ct);
|
||||
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -44,6 +44,7 @@ public class DtoToEntityMappings : Profile
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||
|
||||
CreateMap<CreatePurchaseProductDto, PurchaseProduct>();
|
||||
CreateMap<CreatePurchaseOrderProductDto, PurchaseProduct>();
|
||||
CreateMap<PatchPurchaseProductQuantityDto, PurchaseProduct>()
|
||||
.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<PatchQuotationMessageDto, Quotation>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||
CreateMap<CreateProductQuotationDto, Quotation>();
|
||||
CreateMap<CreateQuotationDto, Quotation>();
|
||||
CreateMap<CreateProductQuotationDto, QuotationProduct>();
|
||||
CreateMap<UpdateQuotationDto, Quotation>()
|
||||
.ForMember(dest => dest.Id, opt => opt.Ignore());
|
||||
|
||||
CreateMap<AddQuotationProductDto, QuotationProduct>();
|
||||
CreateMap<PatchQuotationProductQuantityDto, QuotationProduct>()
|
||||
|
||||
Reference in New Issue
Block a user