From cd7bfe618afe05cee4524db464e1e09047ae2723 Mon Sep 17 00:00:00 2001 From: oistig Date: Thu, 27 Nov 2025 14:52:09 +0100 Subject: [PATCH] correction types warehouses, products et suppliers --- PyroFetes/DTO/Product/Request/CreateProductDto.cs | 4 ++-- PyroFetes/DTO/Product/Request/UpdateProductDto.cs | 4 ++-- PyroFetes/DTO/Product/Response/GetProductDto.cs | 4 ++-- PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs | 12 ++++++------ PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs | 12 ++++++------ PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs | 12 ++++++------ .../DTO/Warehouse/Request/CreateWarehouseDto.cs | 8 ++++---- .../DTO/Warehouse/Request/UpdateWarehouseDto.cs | 8 ++++---- PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs | 8 ++++---- PyroFetes/Endpoints/Product/CreateProductEndpoint.cs | 4 ++-- .../Endpoints/Product/GetAllProductsEndpoint.cs | 4 ++-- PyroFetes/Endpoints/Product/GetProductEndpoint.cs | 2 +- PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs | 4 ++-- .../Endpoints/Warehouse/GetWarehouseEndpoint.cs | 2 +- PyroFetes/Models/Product.cs | 2 +- PyroFetes/Models/Supplier.cs | 2 +- PyroFetes/Models/Warehouse.cs | 2 +- 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/PyroFetes/DTO/Product/Request/CreateProductDto.cs b/PyroFetes/DTO/Product/Request/CreateProductDto.cs index 73e6d3e..5922772 100644 --- a/PyroFetes/DTO/Product/Request/CreateProductDto.cs +++ b/PyroFetes/DTO/Product/Request/CreateProductDto.cs @@ -6,7 +6,7 @@ namespace PyroFetes.DTO.Product.Request public class CreateProductDto { // Référence interne du produit - public int References { get; set; } + public string? Reference { get; set; } // Nom du produit public string? Name { get; set; } @@ -18,7 +18,7 @@ namespace PyroFetes.DTO.Product.Request public decimal Caliber { get; set; } // Numéro d’homologation - public int ApprovalNumber { get; set; } + public string? ApprovalNumber { get; set; } // Poids du produit public decimal Weight { get; set; } diff --git a/PyroFetes/DTO/Product/Request/UpdateProductDto.cs b/PyroFetes/DTO/Product/Request/UpdateProductDto.cs index c499c75..56e1338 100644 --- a/PyroFetes/DTO/Product/Request/UpdateProductDto.cs +++ b/PyroFetes/DTO/Product/Request/UpdateProductDto.cs @@ -9,7 +9,7 @@ namespace PyroFetes.DTO.Product.Request public int Id { get; set; } // Référence interne du produit - public int References { get; set; } + public string? Reference { get; set; } // Nom du produit public string? Name { get; set; } @@ -21,7 +21,7 @@ namespace PyroFetes.DTO.Product.Request public decimal Caliber { get; set; } // Numéro d’homologation - public int ApprovalNumber { get; set; } + public string? ApprovalNumber { get; set; } // Poids du produit public decimal Weight { get; set; } diff --git a/PyroFetes/DTO/Product/Response/GetProductDto.cs b/PyroFetes/DTO/Product/Response/GetProductDto.cs index 6d19b43..53016fb 100644 --- a/PyroFetes/DTO/Product/Response/GetProductDto.cs +++ b/PyroFetes/DTO/Product/Response/GetProductDto.cs @@ -10,7 +10,7 @@ namespace PyroFetes.DTO.Product.Response public int Id { get; set; } // Référence interne du produit - public int Reference { get; set; } + public string? Reference { get; set; } // Nom du produit public string? Name { get; set; } @@ -22,7 +22,7 @@ namespace PyroFetes.DTO.Product.Response public decimal Caliber { get; set; } // Numéro d’homologation - public int ApprovalNumber { get; set; } + public string? ApprovalNumber { get; set; } // Poids du produit public decimal Weight { get; set; } diff --git a/PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs b/PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs index b89b715..d1cdcdd 100644 --- a/PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs +++ b/PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs @@ -4,22 +4,22 @@ public class CreateSupplierDto { // Nom du fournisseur - public string Name { get; set; } + public string? Name { get; set; } // Email du fournisseur - public string Email { get; set; } + public string? Email { get; set; } // Numéro de téléphone du fournisseur - public string PhoneNumber { get; set; } + public string? PhoneNumber { get; set; } // Adresse du fournisseur - public string Adress { get; set; } + public string? Adress { get; set; } // Code postal de l'adresse - public int ZipCode { get; set; } + public string? ZipCode { get; set; } // Ville de l'adresse - public string City { get; set; } + public string? City { get; set; } // Liste des produits fournis par ce fournisseur dans la classe SupplierProductPriceDto public List? Products { get; set; } diff --git a/PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs b/PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs index 6f4ad46..eb991c3 100644 --- a/PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs +++ b/PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs @@ -7,22 +7,22 @@ public int Id { get; set; } // Nom du fournisseur - public string Name { get; set; } + public string? Name { get; set; } // Email du fournisseur - public string Email { get; set; } + public string? Email { get; set; } // Numéro de téléphone du fournisseur - public string PhoneNumber { get; set; } + public string? PhoneNumber { get; set; } // Adresse du fournisseur - public string Adress { get; set; } + public string? Adress { get; set; } // Code postal de l'adresse - public int ZipCode { get; set; } + public string? ZipCode { get; set; } // Ville de l'adresse - public string City { get; set; } + public string? City { get; set; } // Liste des produits fournis par ce fournisseur relié à la classe SupplierProductPriceDto public List? Products { get; set; } diff --git a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs index 01ce76c..5c10fc0 100644 --- a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs +++ b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs @@ -9,22 +9,22 @@ namespace PyroFetes.DTO.Supplier.Response public int Id { get; set; } // Nom du fournisseur - public string Name { get; set; } + public string? Name { get; set; } // Email du fournisseur - public string Email { get; set; } + public string? Email { get; set; } // Numéro de téléphone - public string PhoneNumber { get; set; } + public string? PhoneNumber { get; set; } // Adresse du fournisseur - public string Adress { get; set; } + public string? Adress { get; set; } // Code postal - public int ZipCode { get; set; } + public string? ZipCode { get; set; } // Ville - public string City { get; set; } + public string? City { get; set; } // Liste des produits fournis par la classe SupplierProductPriceDto public List Products { get; set; } = new(); diff --git a/PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs b/PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs index 5864955..91be136 100644 --- a/PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs +++ b/PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs @@ -4,7 +4,7 @@ public class CreateWarehouseDto { // Nom de l'entrepôt - public string Name { get; set; } + public string? Name { get; set; } // Poids maximal que l'entrepôt peut contenir public int MaxWeight { get; set; } @@ -16,13 +16,13 @@ public int MinWeight { get; set; } // Adresse de l'entrepôt - public string Adress { get; set; } + public string? Adress { get; set; } // Code postal - public int ZipCode { get; set; } + public string? ZipCode { get; set; } // Ville - public string City { get; set; } + public string? City { get; set; } // Liste des produits à stocker dans cet entrepôt venant de la classe en dessous public List? Products { get; set; } diff --git a/PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs b/PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs index 673b0de..027f98b 100644 --- a/PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs +++ b/PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs @@ -7,7 +7,7 @@ public int Id { get; set; } // Nom de l'entrepôt - public string Name { get; set; } + public string? Name { get; set; } // Poids maximal que l'entrepôt peut contenir public int MaxWeight { get; set; } @@ -19,13 +19,13 @@ public int MinWeight { get; set; } // Adresse de l'entrepôt - public string Adress { get; set; } + public string? Adress { get; set; } // Code postal - public int ZipCode { get; set; } + public string? ZipCode { get; set; } // Ville - public string City { get; set; } + public string? City { get; set; } // Liste des produits à mettre à jour dans cet entrepôt public List? Products { get; set; } diff --git a/PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs b/PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs index e324f15..32d42be 100644 --- a/PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs +++ b/PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs @@ -7,7 +7,7 @@ public int Id { get; set; } // Nom de l'entrepôt - public string Name { get; set; } + public string? Name { get; set; } // Poids maximal que l'entrepôt peut contenir public int MaxWeight { get; set; } @@ -19,13 +19,13 @@ public int MinWeight { get; set; } // Adresse de l'entrepôt - public string Adress { get; set; } + public string? Adress { get; set; } // Code postal - public int ZipCode { get; set; } + public string? ZipCode { get; set; } // Ville - public string City { get; set; } + public string? City { get; set; } // Liste des produits stockés dans l'entrepôt public List? Products { get; set; } diff --git a/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs b/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs index 45d0809..ffc0c25 100644 --- a/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs +++ b/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs @@ -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, diff --git a/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs b/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs index d7d4182..9447210 100644 --- a/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs +++ b/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs @@ -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, diff --git a/PyroFetes/Endpoints/Product/GetProductEndpoint.cs b/PyroFetes/Endpoints/Product/GetProductEndpoint.cs index 6160e4d..279086a 100644 --- a/PyroFetes/Endpoints/Product/GetProductEndpoint.cs +++ b/PyroFetes/Endpoints/Product/GetProductEndpoint.cs @@ -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, diff --git a/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs b/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs index 71dc6bf..6adecff 100644 --- a/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs +++ b/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs @@ -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, diff --git a/PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs b/PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs index 0e6ab86..737e0d6 100644 --- a/PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs +++ b/PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs @@ -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); diff --git a/PyroFetes/Models/Product.cs b/PyroFetes/Models/Product.cs index f48ee46..66fcf1e 100644 --- a/PyroFetes/Models/Product.cs +++ b/PyroFetes/Models/Product.cs @@ -9,7 +9,7 @@ namespace PyroFetes.Models [Required, MaxLength(100)] public string? Name { get; set; } [Required] public decimal Duration {get; set;} [Required] public decimal Caliber { get; set; } - [Required] public int ApprovalNumber { get; set; } + [Required] public string? ApprovalNumber { get; set; } [Required] public decimal Weight { get; set; } [Required] public decimal Nec { get; set; } [Required] public string? Image { get; set; } diff --git a/PyroFetes/Models/Supplier.cs b/PyroFetes/Models/Supplier.cs index f131804..9ed69ce 100644 --- a/PyroFetes/Models/Supplier.cs +++ b/PyroFetes/Models/Supplier.cs @@ -9,7 +9,7 @@ public class Supplier [Required, MaxLength(100)] public string? Email { get; set; } [Required, MaxLength(30)] public string? Phone { get; set; } [Required, MaxLength(100)] public string? Address { get; set; } - [Required] public int ZipCode { get; set; } + [Required] public string? ZipCode { get; set; } [Required, MaxLength(100)] public string? City { get; set; } [Required] public int DeliveryDelay { get; set; } diff --git a/PyroFetes/Models/Warehouse.cs b/PyroFetes/Models/Warehouse.cs index 8d014e7..86ac934 100644 --- a/PyroFetes/Models/Warehouse.cs +++ b/PyroFetes/Models/Warehouse.cs @@ -10,7 +10,7 @@ public class Warehouse [Required] public int Current {get; set;} [Required] public int MinWeight {get; set;} [Required, MaxLength(100)] public string? Address { get; set; } - [Required] public int ZipCode { get; set; } + [Required] public string? ZipCode { get; set; } [Required, MaxLength(100)] public string? City { get; set; } public List? WarehouseProducts { get; set; }