From 08bf910437da59b7445b45643aca9cc8b909fcbe Mon Sep 17 00:00:00 2001 From: reignem Date: Thu, 9 Oct 2025 15:39:10 +0200 Subject: [PATCH] Maj Warehouse et Supplier --- .../DTO/Product/Request/CreateProductDto.cs | 52 +++++++---------- .../DTO/Product/Request/UpdateProductDto.cs | 51 ++++++++-------- .../DTO/Product/Response/GetProductDto.cs | 58 ++++++++----------- .../Request/ProductSupplierPriceDto.cs | 10 ++++ .../Response/GetProductSupplierDto.cs | 11 ++++ .../Request/ProductWarehouseDto.cs | 17 ++++++ .../Response/GetProductWarehouseDto.cs | 11 ++++ .../Product/CreateProductEndpoint.cs | 2 + .../Product/GetAllProductsEndpoint.cs | 2 + .../Endpoints/Product/GetProductEndpoint.cs | 2 + .../Product/UpdateProductEndpoint.cs | 2 + 11 files changed, 124 insertions(+), 94 deletions(-) create mode 100644 PyroFetes/DTO/ProductSupplierPrice/Request/ProductSupplierPriceDto.cs create mode 100644 PyroFetes/DTO/ProductSupplierPrice/Response/GetProductSupplierDto.cs create mode 100644 PyroFetes/DTO/ProductWarehouse/Request/ProductWarehouseDto.cs create mode 100644 PyroFetes/DTO/ProductWarehouse/Response/GetProductWarehouseDto.cs diff --git a/PyroFetes/DTO/Product/Request/CreateProductDto.cs b/PyroFetes/DTO/Product/Request/CreateProductDto.cs index f5fbd90..ccfac26 100644 --- a/PyroFetes/DTO/Product/Request/CreateProductDto.cs +++ b/PyroFetes/DTO/Product/Request/CreateProductDto.cs @@ -1,36 +1,26 @@ -namespace API.DTO.Product.Request; +using PyroFetes.DTO.Product.Request; -public class CreateProductDto +namespace API.DTO.Product.Request { - public int References { get; set; } - public string? Name { get; set; } - public decimal Duration { get; set; } - public decimal Caliber { get; set; } - public int ApprovalNumber { get; set; } - public decimal Weight { get; set; } - public decimal Nec { get; set; } - public decimal SellingPrice { get; set; } - public string? Image { get; set; } - public string? Link { get; set; } + public class CreateProductDto + { + public int References { get; set; } + public string? Name { get; set; } + public decimal Duration { get; set; } + public decimal Caliber { get; set; } + public int ApprovalNumber { get; set; } + public decimal Weight { get; set; } + public decimal Nec { get; set; } + public decimal SellingPrice { get; set; } + public string? Image { get; set; } + public string? Link { get; set; } + public int ClassificationId { get; set;} + public int ProductCategoryId { get; set; } - public int ClassificationId { get; set;} - public int ProductCategoryId { get; set; } + // Liste des fournisseurs liés au produit + public List? Suppliers { get; set; } - // Liste des fournisseurs liés au produit - public List? Suppliers { get; set; } - - // Liste des entrepôts liés au produit (ajoutée ici) - public List? Warehouses { get; set; } -} - -public class ProductSupplierPriceDto -{ - public int SupplierId { get; set; } - public decimal SellingPrice { get; set; } -} - -public class CreateProductWarehouseDto -{ - public int WarehouseId { get; set; } - public int Quantity { get; set; } + // Liste des entrepôts liés au produit + public List? Warehouses { get; set; } + } } \ No newline at end of file diff --git a/PyroFetes/DTO/Product/Request/UpdateProductDto.cs b/PyroFetes/DTO/Product/Request/UpdateProductDto.cs index 6cb7742..1f64e61 100644 --- a/PyroFetes/DTO/Product/Request/UpdateProductDto.cs +++ b/PyroFetes/DTO/Product/Request/UpdateProductDto.cs @@ -1,32 +1,27 @@ -namespace API.DTO.Product.Request; +using PyroFetes.DTO.Product.Request; -public class UpdateProductDto +namespace API.DTO.Product.Request { - public int Id { get; set; } - public int References { get; set; } - public string? Name { get; set; } - public decimal Duration { get; set; } - public decimal Caliber { get; set; } - public int ApprovalNumber { get; set; } - public decimal Weight { get; set; } - public decimal Nec { get; set; } - public decimal SellingPrice { get; set; } - public string? Image { get; set; } - public string? Link { get; set; } - public int ClassificationId { get; set; } - public int ProductCategoryId { get; set; } + public class UpdateProductDto + { + public int Id { get; set; } + public int References { get; set; } + public string? Name { get; set; } + public decimal Duration { get; set; } + public decimal Caliber { get; set; } + public int ApprovalNumber { get; set; } + public decimal Weight { get; set; } + public decimal Nec { get; set; } + public decimal SellingPrice { get; set; } + public string? Image { get; set; } + public string? Link { get; set; } + public int ClassificationId { get; set; } + public int ProductCategoryId { get; set; } - // Liste des fournisseurs associés - public List Suppliers { get; set; } + // Liste des fournisseurs associés + public List Suppliers { get; set; } = new(); - // Liste des entrepôts associés (corrigé ici) - public List Warehouses { get; set; } -} - -// DTO pour la mise à jour des entrepôts liés -public class UpdateProductWarehouseDto -{ - public int WarehouseId { get; set; } - public int Quantity { get; set; } - -} + // Liste des entrepôts associés + public List Warehouses { get; set; } = new(); + } +} \ No newline at end of file diff --git a/PyroFetes/DTO/Product/Response/GetProductDto.cs b/PyroFetes/DTO/Product/Response/GetProductDto.cs index 337fc4a..576f7e0 100644 --- a/PyroFetes/DTO/Product/Response/GetProductDto.cs +++ b/PyroFetes/DTO/Product/Response/GetProductDto.cs @@ -1,41 +1,29 @@ using API.DTO.Product.Request; +using PyroFetes.DTO.Product.Request; +using PyroFetes.DTO.Product.Response; -namespace API.DTO.Product.Response; - -public class GetProductDto +namespace API.DTO.Product.Response { - public int Id { get; set; } - public int Reference { get; set; } - public string? Name { get; set; } - public decimal Duration { get; set; } - public decimal Caliber { get; set; } - public int ApprovalNumber { get; set; } - public decimal Weight { get; set; } - public decimal Nec { get; set; } - public decimal SellingPrice { get; set; } - public string? Image { get; set; } - public string? Link { get; set; } - public int ClassificationId { get; set; } - public int ProductCategoryId { get; set; } + public class GetProductDto + { + public int Id { get; set; } + public int Reference { get; set; } + public string? Name { get; set; } + public decimal Duration { get; set; } + public decimal Caliber { get; set; } + public int ApprovalNumber { get; set; } + public decimal Weight { get; set; } + public decimal Nec { get; set; } + public decimal SellingPrice { get; set; } + public string? Image { get; set; } + public string? Link { get; set; } + public int ClassificationId { get; set; } + public int ProductCategoryId { get; set; } - // Liste des fournisseurs liés avec leur prix de vente - public List Suppliers { get; set; } - - public List Warehouses { get; set; } = new(); -} + // Fournisseurs liés + public List Suppliers { get; set; } = new(); - -public class GetProductSupplierDto -{ - public int SupplierId { get; set; } - public string SupplierName { get; set; } = string.Empty; - public decimal SellingPrice { get; set; } - -} - -public class GetProductWarehouseDto -{ - public int WarehouseId { get; set; } - public string WarehouseName { get; set; } = string.Empty; - public int Quantity { get; set; } + // Entrepôts liés + public List Warehouses { get; set; } = new(); + } } \ No newline at end of file diff --git a/PyroFetes/DTO/ProductSupplierPrice/Request/ProductSupplierPriceDto.cs b/PyroFetes/DTO/ProductSupplierPrice/Request/ProductSupplierPriceDto.cs new file mode 100644 index 0000000..f48ba0a --- /dev/null +++ b/PyroFetes/DTO/ProductSupplierPrice/Request/ProductSupplierPriceDto.cs @@ -0,0 +1,10 @@ +namespace PyroFetes.DTO.Product.Request +{ + // DTO utilisé pour créer ou mettre à jour la relation Product <-> Supplier + public class ProductSupplierPriceDto + { + public int ProductId { get; set; } // Id du produit (pour update) + public int SupplierId { get; set; } // Id du fournisseur + public decimal SellingPrice { get; set; } // Prix de vente + } +} diff --git a/PyroFetes/DTO/ProductSupplierPrice/Response/GetProductSupplierDto.cs b/PyroFetes/DTO/ProductSupplierPrice/Response/GetProductSupplierDto.cs new file mode 100644 index 0000000..a423279 --- /dev/null +++ b/PyroFetes/DTO/ProductSupplierPrice/Response/GetProductSupplierDto.cs @@ -0,0 +1,11 @@ +namespace PyroFetes.DTO.Product.Response +{ +// DTO pour la lecture des fournisseurs liés à un produit +public class GetProductSupplierDto +{ + public int ProductId { get; set; } + public int SupplierId { get; set; } + public string SupplierName { get; set; } = string.Empty; + public decimal SellingPrice { get; set; } +} +} diff --git a/PyroFetes/DTO/ProductWarehouse/Request/ProductWarehouseDto.cs b/PyroFetes/DTO/ProductWarehouse/Request/ProductWarehouseDto.cs new file mode 100644 index 0000000..a74cab2 --- /dev/null +++ b/PyroFetes/DTO/ProductWarehouse/Request/ProductWarehouseDto.cs @@ -0,0 +1,17 @@ +namespace PyroFetes.DTO.Product.Request +{ + // DTO utilisé pour créer ou mettre à jour la relation Product <-> Warehouse + public class CreateProductWarehouseDto + { + public int WarehouseId { get; set; } + public int ProductId { get; set; } + public int Quantity { get; set; } + } + + public class UpdateProductWarehouseDto + { + public int WarehouseId { get; set; } + public int ProductId { get; set; } + public int Quantity { get; set; } + } +} \ No newline at end of file diff --git a/PyroFetes/DTO/ProductWarehouse/Response/GetProductWarehouseDto.cs b/PyroFetes/DTO/ProductWarehouse/Response/GetProductWarehouseDto.cs new file mode 100644 index 0000000..40a28fb --- /dev/null +++ b/PyroFetes/DTO/ProductWarehouse/Response/GetProductWarehouseDto.cs @@ -0,0 +1,11 @@ +namespace PyroFetes.DTO.Product.Response +{ + // DTO pour la lecture des entrepôts liés à un produit + public class GetProductWarehouseDto + { + public int WarehouseId { get; set; } + public int ProductId { get; set; } + public string WarehouseName { get; set; } = string.Empty; + public int Quantity { get; set; } + } +} \ No newline at end of file diff --git a/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs b/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs index 3e0e92c..7f4233c 100644 --- a/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs +++ b/PyroFetes/Endpoints/Product/CreateProductEndpoint.cs @@ -2,6 +2,8 @@ using API.DTO.Product.Response; using FastEndpoints; using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Product.Request; +using PyroFetes.DTO.Product.Response; using PyroFetes.Models; namespace PyroFetes.Endpoints.Product; diff --git a/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs b/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs index dcb89fd..d1d1a75 100644 --- a/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs +++ b/PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs @@ -2,6 +2,8 @@ using API.DTO.Product.Response; using FastEndpoints; using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Product.Request; +using PyroFetes.DTO.Product.Response; using PyroFetes.Models; namespace PyroFetes.Endpoints.Product; diff --git a/PyroFetes/Endpoints/Product/GetProductEndpoint.cs b/PyroFetes/Endpoints/Product/GetProductEndpoint.cs index db3baf7..d9e70dd 100644 --- a/PyroFetes/Endpoints/Product/GetProductEndpoint.cs +++ b/PyroFetes/Endpoints/Product/GetProductEndpoint.cs @@ -2,6 +2,8 @@ using API.DTO.Product.Response; using FastEndpoints; using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Product.Request; +using PyroFetes.DTO.Product.Response; using PyroFetes.Models; namespace PyroFetes.Endpoints.Product; diff --git a/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs b/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs index 15ed7fe..a5b91c2 100644 --- a/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs +++ b/PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs @@ -2,6 +2,8 @@ using API.DTO.Product.Response; using FastEndpoints; using Microsoft.EntityFrameworkCore; +using PyroFetes.DTO.Product.Request; +using PyroFetes.DTO.Product.Response; using PyroFetes.Models; namespace PyroFetes.Endpoints.Product;