forked from sanchezvem/PyroFetes
correction types warehouses, products et suppliers
This commit is contained in:
@@ -19,7 +19,7 @@ public class CreateProductEndpoint(PyroFetesDbContext db)
|
||||
{
|
||||
var product = new Models.Product
|
||||
{
|
||||
Reference = req.References.ToString(),
|
||||
Reference = req.Reference,
|
||||
Name = req.Name!,
|
||||
Duration = req.Duration,
|
||||
Caliber = req.Caliber,
|
||||
@@ -75,7 +75,7 @@ public class CreateProductEndpoint(PyroFetesDbContext db)
|
||||
var response = new GetProductDto
|
||||
{
|
||||
Id = product.Id,
|
||||
Reference = req.References,
|
||||
Reference = req.Reference,
|
||||
Name = req.Name,
|
||||
Duration = req.Duration,
|
||||
Caliber = req.Caliber,
|
||||
|
||||
@@ -20,7 +20,7 @@ public class GetAllProductsEndpoint(PyroFetesDbContext db)
|
||||
// Inclure toutes les relations nécessaires : Prices + WarehouseProducts + Warehouse
|
||||
var products = await db.Products
|
||||
.Include(p => p.Prices)
|
||||
.Include(p => p.WarehouseProducts)
|
||||
.Include(p => p.WarehouseProducts)!
|
||||
.ThenInclude(wp => wp.Warehouse)
|
||||
.ToListAsync(ct);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class GetAllProductsEndpoint(PyroFetesDbContext db)
|
||||
{
|
||||
Id = p.Id,
|
||||
// Le modèle Product contient "Reference" (string) — pas "References" (int)
|
||||
Reference = int.TryParse(p.Reference, out var refInt) ? refInt : 0,
|
||||
Reference = p.Reference,
|
||||
Name = p.Name,
|
||||
Duration = p.Duration,
|
||||
Caliber = p.Caliber,
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GetProductEndpoint(PyroFetesDbContext db)
|
||||
Id = product.Id,
|
||||
|
||||
// Le modèle Product contient "Reference" (string), pas "References" (int)
|
||||
Reference = int.TryParse(product.Reference, out var refInt) ? refInt : 0,
|
||||
Reference = product.Reference,
|
||||
|
||||
Name = product.Name,
|
||||
Duration = product.Duration,
|
||||
|
||||
@@ -35,7 +35,7 @@ public class UpdateProductEndpoint(PyroFetesDbContext db)
|
||||
}
|
||||
|
||||
// Mise à jour des propriétés principales du produit
|
||||
product.Reference = req.References.ToString(); // Converti int → string
|
||||
product.Reference = req.Reference; // Converti int → string
|
||||
product.Name = req.Name;
|
||||
product.Duration = req.Duration;
|
||||
product.Caliber = req.Caliber;
|
||||
@@ -77,7 +77,7 @@ public class UpdateProductEndpoint(PyroFetesDbContext db)
|
||||
var response = new GetProductDto
|
||||
{
|
||||
Id = product.Id,
|
||||
Reference = req.References, // DTO garde int pour cohérence
|
||||
Reference = req.Reference, // DTO garde int pour cohérence
|
||||
Name = req.Name,
|
||||
Duration = req.Duration,
|
||||
Caliber = req.Caliber,
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GetWarehouseEndpoint(PyroFetesDbContext db)
|
||||
{
|
||||
// 🔹 Inclut les produits associés à cet entrepôt
|
||||
var warehouse = await db.Warehouses
|
||||
.Include(w => w.WarehouseProducts)
|
||||
.Include(w => w.WarehouseProducts)!
|
||||
.ThenInclude(wp => wp.Product)
|
||||
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user