12 Commits

Author SHA1 Message Date
4c0e7df9de MAJ 2025-10-16 17:09:29 +02:00
5506eab8ff Merge branch 'feature/mathy' into develop
# Conflicts:
#	PyroFetes/Endpoints/Brand/UpdateBrandEndpoint.cs
#	PyroFetes/Endpoints/Warehouse/DeleteWarehouseEndpoint.cs
#	PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs
#	PyroFetes/Endpoints/Warehouse/UpdateWarehouseEndpoint.cs
2025-10-16 17:08:38 +02:00
15545980af Normalement c'est réglé ! 2025-10-16 17:03:51 +02:00
dda2240e86 Merge branch 'feature/gabriel2' into develop 2025-10-16 16:46:33 +02:00
a014c6c9f7 gabriel2 2025-10-16 16:42:45 +02:00
2112605cf3 Ajout de Login et du model réuni avec tout les autres Sujet 2025-10-16 16:30:17 +02:00
90d685d42c Commentaire create color endpooint 2025-10-16 16:25:19 +02:00
2bcca6f856 Merge remote-tracking branch 'origin/develop' into develop 2025-10-16 15:52:52 +02:00
6d564c89ff Correction des routes d'api 2025-10-16 15:52:24 +02:00
bad259e9f5 MAJ 2025-10-10 11:39:36 +02:00
32dee6eb18 Merge branch 'feature/mathy' into develop 2025-10-10 11:37:56 +02:00
b3347fe163 Commentaire des DTO 2025-10-10 11:21:57 +02:00
76 changed files with 1003 additions and 308 deletions

View File

@@ -1,7 +1,9 @@
namespace API.DTO.Brand.Request;
public class CreateBrandDto
namespace PyroFetes.DTO.Brand.Request
{
public string? Name { get; set; }
// DTO pour créer une nouvelle marque
public class CreateBrandDto
{
// Nom de la marque
public string? Name { get; set; }
}
}

View File

@@ -1,8 +1,12 @@
namespace API.DTO.Brand.Request;
public class UpdateBrandDto
namespace PyroFetes.DTO.Brand.Request
{
public int Id { get; set; }
public string? Name { get; set; }
// DTO pour mettre à jour une marque existante
public class UpdateBrandDto
{
// Identifiant de la marque à mettre à jour
public int Id { get; set; }
// Nouveau nom de la marque
public string? Name { get; set; }
}
}

View File

@@ -1,8 +1,12 @@
namespace API.DTO.Brand.Response;
public class GetBrandDto
namespace API.DTO.Brand.Response
{
public int Id { get; set; }
public string? Name { get; set; }
// DTO pour récupérer les informations d'une marque
public class GetBrandDto
{
// Identifiant de la marque
public int Id { get; set; }
// Nom de la marque
public string? Name { get; set; }
}
}

View File

@@ -1,7 +1,11 @@
namespace API.DTO.Classification.Request;
public class CreateClassificationDto
// Définition de l'espace de noms pour les DTO liés à la création de classifications
namespace API.DTO.Classification.Request
{
public string? Label { get; set; }
// DTO (Data Transfer Object) utilisé pour créer une nouvelle classification
public class CreateClassificationDto
{
// Propriété représentant le nom ou le label de la classification
// Le type "string?" signifie que cette valeur peut être null
public string? Label { get; set; }
}
}

View File

@@ -1,8 +1,15 @@
namespace API.DTO.Classification.Request;
public class UpdateClassificationDto
// Définition de l'espace de noms pour les DTO liés à la mise à jour de classifications
namespace API.DTO.Classification.Request
{
public int Id { get; set; }
public string? Label { get; set; }
// DTO (Data Transfer Object) utilisé pour mettre à jour une classification existante
public class UpdateClassificationDto
{
// Propriété représentant l'ID unique de la classification à mettre à jour
public int Id { get; set; }
// Propriété représentant le nouveau nom ou label de la classification
// Le type "string?" signifie que cette valeur peut être null
// Si null, le label ne sera pas modifié
public string? Label { get; set; }
}
}

View File

@@ -1,8 +1,14 @@
namespace API.DTO.Classification.Response;
public class GetClassificationDto
// Définition de l'espace de noms pour les DTO utilisés dans les réponses liées aux classifications
namespace API.DTO.Classification.Response
{
public int Id { get; set; }
public string? Label { get; set; }
// DTO (Data Transfer Object) utilisé pour renvoyer les informations d'une classification
public class GetClassificationDto
{
// Propriété représentant l'ID unique de la classification
public int Id { get; set; }
// Propriété représentant le nom ou label de la classification
// Le type "string?" signifie que cette valeur peut être null si la classification n'a pas de label
public string? Label { get; set; }
}
}

View File

@@ -1,6 +1,11 @@
namespace API.DTO.Color.Request;
public class CreateColorDto
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux couleurs
namespace API.DTO.Color.Request
{
public string? Label { get; set; }
// DTO utilisé pour créer une nouvelle couleur
public class CreateColorDto
{
// Propriété représentant le nom ou label de la couleur à créer
// Le type "string?" signifie que cette valeur peut être null si le label n'est pas fourni
public string? Label { get; set; }
}
}

View File

@@ -1,7 +1,14 @@
namespace API.DTO.Color.Request;
public class UpdateColorDto
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux couleurs
namespace API.DTO.Color.Request
{
public int Id { get; set; }
public string? Label { get; set; }
// DTO utilisé pour mettre à jour une couleur existante
public class UpdateColorDto
{
// Identifiant unique de la couleur à mettre à jour
public int Id { get; set; }
// Nouveau nom ou label de la couleur
// Le type "string?" signifie que cette valeur peut être null si aucun changement n'est fourni
public string? Label { get; set; }
}
}

View File

@@ -1,7 +1,14 @@
namespace API.DTO.Color.Response;
public class GetColorDto
// Définition de l'espace de noms pour les DTO utilisés dans les réponses liées aux couleurs
namespace API.DTO.Color.Response
{
public int Id { get; set; }
public string? Label { get; set; }
// DTO utilisé pour renvoyer les informations d'une couleur
public class GetColorDto
{
// Identifiant unique de la couleur
public int Id { get; set; }
// Nom ou label de la couleur
// Le type "string?" signifie que cette valeur peut être null si le label n'est pas défini
public string? Label { get; set; }
}
}

View File

@@ -1,6 +1,11 @@
namespace API.DTO.Effect.Request;
public class CreateEffectDto
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux effets
namespace API.DTO.Effect.Request
{
public string? Label { get; set; }
// DTO utilisé pour créer un nouvel effet
public class CreateEffectDto
{
// Nom ou label de l'effet
// Le type "string?" signifie que cette valeur peut être null si aucun label n'est fourni
public string? Label { get; set; }
}
}

View File

@@ -1,7 +1,14 @@
namespace API.DTO.Effect.Request;
public class UpdateEffectDto
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux effets
namespace API.DTO.Effect.Request
{
public int Id { get; set; }
public string? Label { get; set; }
// DTO utilisé pour mettre à jour un effet existant
public class UpdateEffectDto
{
// Identifiant unique de l'effet à mettre à jour
public int Id { get; set; }
// Nouveau nom ou label de l'effet
// Le type "string?" signifie que cette valeur peut être null si aucun label n'est fourni
public string? Label { get; set; }
}
}

View File

@@ -1,7 +1,14 @@
namespace API.DTO.Effect.Response;
public class GetEffectDto
// Définition de l'espace de noms pour les DTO utilisés dans les réponses liées aux effets
namespace API.DTO.Effect.Response
{
public int Id { get; set; }
public string? Label { get; set; }
// DTO utilisé pour renvoyer les informations d'un effet
public class GetEffectDto
{
// Identifiant unique de l'effet
public int Id { get; set; }
// Nom ou label de l'effet
// Le type "string?" signifie que cette valeur peut être null si aucune valeur n'est disponible
public string? Label { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Login.Request;
public class ConnectLoginDto
{
public string? Username { get; set; }
public string? Password { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.Login.Request;
public class CreateLoginDto
{
public string? Username { get; set; }
public string? FullName { get; set; }
public string? Password { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace PyroFetes.DTO.Login.Request;
public class UpdateLoginDto
{
public int Id { get; set; }
public string? Username { get; set; }
public string? FullName { get; set; }
public string? Password { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.Login.Response;
public class GetLoginConnectDto
{
public string? Token { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace PyroFetes.DTO.Login.Response;
public class GetLoginDto
{
public int Id { get; set; }
public string? Username { get; set; }
public string? FullName { get; set; }
public string? Password { get; set; }
public string? Salt { get; set; }
}

View File

@@ -1,9 +1,17 @@
namespace API.DTO.Material.Request;
public class CreateMaterialDto
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux matériaux
namespace API.DTO.Material.Request
{
public string? Label { get; set; }
public int Quantity { get; set; }
public int WarehouseId {get; set;}
// DTO utilisé pour créer un nouveau matériau
public class CreateMaterialDto
{
// Nom ou label du matériau
// Le type "string?" signifie que cette valeur peut être null si aucune valeur n'est fournie
public string? Label { get; set; }
// Quantité du matériau à créer
public int Quantity { get; set; }
// Identifiant de l'entrepôt dans lequel le matériau sera stocké
public int WarehouseId { get; set; }
}
}

View File

@@ -1,10 +1,20 @@
namespace API.DTO.Material.Request;
public class UpdateMaterialDto
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux matériaux
namespace API.DTO.Material.Request
{
public int Id { get; set; }
public string? Label { get; set; }
public int Quantity { get; set; }
public int WarehouseId {get; set;}
// DTO utilisé pour mettre à jour un matériau existant
public class UpdateMaterialDto
{
// Identifiant unique du matériau à mettre à jour
public int Id { get; set; }
// Nom ou label du matériau
// Le type "string?" signifie que cette valeur peut être null si aucune valeur n'est fournie
public string? Label { get; set; }
// Quantité mise à jour du matériau
public int Quantity { get; set; }
// Identifiant de l'entrepôt associé au matériau
public int WarehouseId { get; set; }
}
}

View File

@@ -1,10 +1,20 @@
namespace API.DTO.Material.Response;
public class GetMaterialDto
// Définition de l'espace de noms pour les DTO utilisés dans les réponses liées aux matériaux
namespace API.DTO.Material.Response
{
public int Id { get; set; }
public string? Label { get; set; }
public int Quantity { get; set; }
public int WarehouseId {get; set;}
// DTO utilisé pour renvoyer les informations d'un matériau
public class GetMaterialDto
{
// Identifiant unique du matériau
public int Id { get; set; }
// Nom ou label du matériau
// Le type "string?" signifie que cette valeur peut être null si aucune valeur n'est définie
public string? Label { get; set; }
// Quantité disponible du matériau
public int Quantity { get; set; }
// Identifiant de l'entrepôt auquel le matériau est associé
public int WarehouseId { get; set; }
}
}

View File

@@ -1,10 +1,19 @@
namespace API.DTO.Movement.Request;
public class CreateMovementDto
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux mouvements
namespace API.DTO.Movement.Request
{
public DateTime Date { get; set; }
public DateTime Start {get; set;}
public DateTime Arrival {get; set;}
public int Quantity {get; set;}
// DTO utilisé pour créer un nouveau mouvement
public class CreateMovementDto
{
// Date à laquelle le mouvement est enregistré
public DateTime Date { get; set; }
// Date et heure de début du mouvement
public DateTime Start { get; set; }
// Date et heure d'arrivée prévue du mouvement
public DateTime Arrival { get; set; }
// Quantité de matériaux ou objets impliqués dans le mouvement
public int Quantity { get; set; }
}
}

View File

@@ -1,11 +1,22 @@
namespace API.DTO.Movement.Request;
public class UpdateMovementDto
// Définition de l'espace de noms pour les DTO utilisés dans les requêtes liées aux mouvements
namespace API.DTO.Movement.Request
{
public int Id { get; set; }
public DateTime Date { get; set; }
public DateTime Start {get; set;}
public DateTime Arrival {get; set;}
public int Quantity {get; set;}
// DTO utilisé pour mettre à jour un mouvement existant
public class UpdateMovementDto
{
// ID unique du mouvement à mettre à jour
public int Id { get; set; }
// Date à laquelle le mouvement est enregistré
public DateTime Date { get; set; }
// Date et heure de début du mouvement
public DateTime Start { get; set; }
// Date et heure d'arrivée prévue du mouvement
public DateTime Arrival { get; set; }
// Quantité de matériaux ou objets impliqués dans le mouvement
public int Quantity { get; set; }
}
}

View File

@@ -1,11 +1,22 @@
namespace API.DTO.Movement.Response;
public class GetMovementDto
// Définition de l'espace de noms pour les DTO utilisés dans les réponses liées aux mouvements
namespace API.DTO.Movement.Response
{
public int Id { get; set; }
public DateTime Date { get; set; }
public DateTime Start {get; set;}
public DateTime Arrival {get; set;}
public int Quantity {get; set;}
// DTO utilisé pour renvoyer les informations d'un mouvement
public class GetMovementDto
{
// ID unique du mouvement
public int Id { get; set; }
// Date à laquelle le mouvement est enregistré
public DateTime Date { get; set; }
// Date et heure de début du mouvement
public DateTime Start { get; set; }
// Date et heure d'arrivée prévue du mouvement
public DateTime Arrival { get; set; }
// Quantité de matériaux ou objets impliqués dans le mouvement
public int Quantity { get; set; }
}
}

View File

@@ -2,25 +2,49 @@
namespace PyroFetes.DTO.Product.Request
{
// DTO utilisé lors de la création dun produit
public class CreateProductDto
{
// Référence interne du produit
public int References { get; set; }
// Nom du produit
public string? Name { get; set; }
// Durée de leffet du produit
public decimal Duration { get; set; }
// Calibre du produit
public decimal Caliber { get; set; }
// Numéro dhomologation
public int ApprovalNumber { get; set; }
// Poids du produit
public decimal Weight { get; set; }
// Matière active (NEC)
public decimal Nec { get; set; }
// Prix de vente du produit
public decimal SellingPrice { get; set; }
// Image associée au produit (URL ou chemin)
public string? Image { get; set; }
// Lien vers une ressource externe (vidéo, fiche, etc.)
public string? Link { get; set; }
public int ClassificationId { get; set;}
// Identifiant de la classification du produit
public int ClassificationId { get; set; }
// Identifiant de la catégorie du produit
public int ProductCategoryId { get; set; }
// Liste des fournisseurs liés au produit
// Liste des fournisseurs liés au produit venant du DTO ProductSupplierPriceDto
public List<ProductSupplierPriceDto>? Suppliers { get; set; }
// Liste des entrepôts liés au produit
// Liste des entrepôts liés au produit venant du DTO CreateProductWarehouseDto
public List<CreateProductWarehouseDto>? Warehouses { get; set; }
}
}

View File

@@ -2,26 +2,52 @@
namespace PyroFetes.DTO.Product.Request
{
// DTO utilisé pour la mise à jour dun produit existant
public class UpdateProductDto
{
// Identifiant unique du produit à modifier
public int Id { get; set; }
// Référence interne du produit
public int References { get; set; }
// Nom du produit
public string? Name { get; set; }
// Durée de leffet du produit
public decimal Duration { get; set; }
// Calibre du produit
public decimal Caliber { get; set; }
// Numéro dhomologation
public int ApprovalNumber { get; set; }
// Poids du produit
public decimal Weight { get; set; }
// Matière active (NEC)
public decimal Nec { get; set; }
// Prix de vente du produit
public decimal SellingPrice { get; set; }
// Image associée au produit (URL ou chemin)
public string? Image { get; set; }
// Lien vers une ressource externe (fiche, vidéo, etc.)
public string? Link { get; set; }
// Identifiant de la classification du produit
public int ClassificationId { get; set; }
// Identifiant de la catégorie du produit
public int ProductCategoryId { get; set; }
// Liste des fournisseurs associés
// Liste des fournisseurs associés venant du DTO ProductSupplierPriceDto
public List<ProductSupplierPriceDto> Suppliers { get; set; } = new();
// Liste des entrepôts associés
// Liste des entrepôts associés venant du DTO UpdateProductWarehouseDto
public List<UpdateProductWarehouseDto> Warehouses { get; set; } = new();
}
}

View File

@@ -1,29 +1,54 @@
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response;
namespace PyroFetes.DTO.Product.Response
{
// DTO utilisé pour renvoyer les informations complètes dun produit
public class GetProductDto
{
// Identifiant unique du produit
public int Id { get; set; }
// Référence interne du produit
public int Reference { get; set; }
// Nom du produit
public string? Name { get; set; }
// Durée de leffet du produit
public decimal Duration { get; set; }
// Calibre du produit
public decimal Caliber { get; set; }
// Numéro dhomologation
public int ApprovalNumber { get; set; }
// Poids du produit
public decimal Weight { get; set; }
// Matière active (NEC)
public decimal Nec { get; set; }
// Prix de vente du produit
public decimal SellingPrice { get; set; }
// Image du produit (URL ou chemin)
public string? Image { get; set; }
// Lien externe vers plus dinformations (fiche, vidéo, etc.)
public string? Link { get; set; }
// Identifiant de la classification du produit
public int ClassificationId { get; set; }
// Identifiant de la catégorie du produit
public int ProductCategoryId { get; set; }
// Fournisseurs liés
// Fournisseurs liés venant du DTO ProductSupplierPriceDto
public List<ProductSupplierPriceDto> Suppliers { get; set; } = new();
// Entrepôts liés
// Entrepôts liés venant du DTO ProductWarehouseDto
public List<GetProductWarehouseDto> Warehouses { get; set; } = new();
}
}

View File

@@ -1,6 +1,9 @@
namespace API.DTO.ProductCategory.Request;
public class CreateProductCategoryDto
namespace API.DTO.ProductCategory.Request
{
public string? Label { get; set; }
// DTO pour créer une catégorie de produit
public class CreateProductCategoryDto
{
// Nom de la catégorie
public string? Label { get; set; }
}
}

View File

@@ -1,7 +1,12 @@
namespace API.DTO.ProductCategory.Request;
public class UpdateProductCategoryDto
namespace API.DTO.ProductCategory.Request
{
public int Id { get; set; }
public string? Label { get; set; }
// DTO pour mettre à jour une catégorie de produit
public class UpdateProductCategoryDto
{
// Identifiant de la catégorie
public int Id { get; set; }
// Nom de la catégorie
public string? Label { get; set; }
}
}

View File

@@ -1,8 +1,12 @@
namespace API.DTO.ProductCategory.Response;
public class GetProductCategoryDto
namespace API.DTO.ProductCategory.Response
{
public int Id { get; set; }
public string? Label { get; set; }
// DTO pour récupérer une catégorie de produit
public class GetProductCategoryDto
{
// Identifiant de la catégorie
public int Id { get; set; }
// Nom de la catégorie
public string? Label { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.ProductColor.Request;
// DTO utilisé pour créer ou mettre à jour la relation Product <-> Color
public class ProductColorDto
{
public int ProductId { get; set; } // Id du produit (pour update)
public int ColorId { get; set; } // Id de la couleur
}

View File

@@ -0,0 +1,11 @@
namespace PyroFetes.DTO.ProductColor.Response;
// DTO utilisé pour renvoyer les informations dun produit lié à une couleur
public class GetProductColorDto
{
// Identifiant du produit concerné
public int ProductId { get; set; }
// Identifiant de la couleur
public int ColorId { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.ProductEffect.Request;
// DTO utilisé pour créer ou mettre à jour la relation Product <-> Effect
public class ProductEffectDto
{
public int ProductId { get; set; } // Id du produit (pour update)
public int EffectId { get; set; } // Id de l'effet
}

View File

@@ -0,0 +1,12 @@
namespace PyroFetes.DTO.ProductEffect.Response;
// DTO utilisé pour renvoyer les informations dun produit lié à un effet
public class GetProductEffectDto
{
// Identifiant du produit concerné
public int ProductId { get; set; }
// Identifiant de l'effet
public int EffectId { get; set; }
}

View File

@@ -1,11 +1,18 @@
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; }
}
}
// DTO utilisé pour renvoyer les informations dun fournisseur lié à un produit
public class GetProductSupplierDto
{
// Identifiant du produit concerné
public int ProductId { get; set; }
// Identifiant du fournisseur
public int SupplierId { get; set; }
// Nom du fournisseur
public string SupplierName { get; set; } = string.Empty;
// Prix de vente du produit fourni par ce fournisseur
public decimal SellingPrice { get; set; }
}
}

View File

@@ -1,17 +1,28 @@
namespace PyroFetes.DTO.Product.Request
{
// DTO utilisé pour créer ou mettre à jour la relation Product <-> Warehouse
// DTO utilisé lors de la création dune relation entre un produit et un entrepôt
public class CreateProductWarehouseDto
{
// Identifiant de l'entrepôt concerné
public int WarehouseId { get; set; }
// Identifiant du produit associé à cet entrepôt
public int ProductId { get; set; }
// Quantité du produit disponible dans cet entrepôt
public int Quantity { get; set; }
}
// DTO utilisé lors de la mise à jour dune relation entre un produit et un entrepôt
public class UpdateProductWarehouseDto
{
// Identifiant de l'entrepôt concerné
public int WarehouseId { get; set; }
// Identifiant du produit associé à cet entrepôt
public int ProductId { get; set; }
// Nouvelle quantité du produit dans cet entrepôt
public int Quantity { get; set; }
}
}

View File

@@ -1,11 +1,18 @@
namespace PyroFetes.DTO.Product.Response
{
// DTO pour la lecture des entrepôts liés à un produit
// DTO utilisé pour renvoyer les informations dun entrepôt lié à un produit
public class GetProductWarehouseDto
{
// Identifiant de l'entrepôt
public int WarehouseId { get; set; }
// Identifiant du produit associé à cet entrepôt
public int ProductId { get; set; }
// Nom de l'entrepôt (utile pour laffichage)
public string WarehouseName { get; set; } = string.Empty;
// Quantité du produit stockée dans cet entrepôt
public int Quantity { get; set; }
}
}

View File

@@ -1,20 +1,37 @@
namespace PyroFetes.DTO.Supplier.Request;
public class CreateSupplierDto
namespace PyroFetes.DTO.Supplier.Request
{
public string Name { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
public string Adress { get; set; }
public int ZipCode { get; set; }
public string City { get; set; }
// DTO pour créer un nouveau fournisseur
public class CreateSupplierDto
{
// Nom du fournisseur
public string Name { get; set; }
// Produits que ce fournisseur fournit
public List<SupplierProductPriceDto>? Products { get; set; }
}
// Email du fournisseur
public string Email { get; set; }
public class SupplierProductPriceDto
{
public int ProductId { get; set; }
public decimal SellingPrice { get; set; }
// Numéro de téléphone du fournisseur
public string PhoneNumber { get; set; }
// Adresse du fournisseur
public string Adress { get; set; }
// Code postal de l'adresse
public int ZipCode { get; set; }
// Ville de l'adresse
public string City { get; set; }
// Liste des produits fournis par ce fournisseur dans la classe SupplierProductPriceDto
public List<SupplierProductPriceDto>? Products { get; set; }
}
// DTO pour relier un produit et son prix à un fournisseur
public class SupplierProductPriceDto
{
// Identifiant du produit fourni
public int ProductId { get; set; }
// Prix de vente du produit par ce fournisseur
public decimal SellingPrice { get; set; }
}
}

View File

@@ -1,14 +1,30 @@
namespace PyroFetes.DTO.Supplier.Request;
public class UpdateSupplierDto
namespace PyroFetes.DTO.Supplier.Request
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
public string Adress { get; set; }
public int ZipCode { get; set; }
public string City { get; set; }
// DTO pour mettre à jour un fournisseur existant
public class UpdateSupplierDto
{
// Identifiant du fournisseur à mettre à jour
public int Id { get; set; }
public List<SupplierProductPriceDto>? Products { get; set; }
// Nom du fournisseur
public string Name { get; set; }
// Email du fournisseur
public string Email { get; set; }
// Numéro de téléphone du fournisseur
public string PhoneNumber { get; set; }
// Adresse du fournisseur
public string Adress { get; set; }
// Code postal de l'adresse
public int ZipCode { get; set; }
// Ville de l'adresse
public string City { get; set; }
// Liste des produits fournis par ce fournisseur relié à la classe SupplierProductPriceDto
public List<SupplierProductPriceDto>? Products { get; set; }
}
}

View File

@@ -1,24 +1,45 @@
using PyroFetes.DTO.Supplier.Request;
namespace PyroFetes.DTO.Supplier.Response;
public class GetSupplierDto
namespace PyroFetes.DTO.Supplier.Response
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
public string Adress { get; set; }
public int ZipCode { get; set; }
public string City { get; set; }
// DTO pour récupérer les informations d'un fournisseur
public class GetSupplierDto
{
// Identifiant du fournisseur
public int Id { get; set; }
// Liste des produits liés avec leur prix fournisseur
public List<SupplierProductPriceDto> Products { get; set; }
}
// Nom du fournisseur
public string Name { get; set; }
public class GetSupplierProductDto
{
public int ProductId { get; set; }
public string ProductName { get; set; } = string.Empty;
public decimal SellingPrice { get; set; }
// Email du fournisseur
public string Email { get; set; }
// Numéro de téléphone
public string PhoneNumber { get; set; }
// Adresse du fournisseur
public string Adress { get; set; }
// Code postal
public int ZipCode { get; set; }
// Ville
public string City { get; set; }
// Liste des produits fournis par la classe SupplierProductPriceDto
public List<SupplierProductPriceDto> Products { get; set; } = new();
}
// DTO pour les détails d'un produit lié à un fournisseur
public class GetSupplierProductDto
{
// Identifiant du produit
public int ProductId { get; set; }
// Nom du produit
public string ProductName { get; set; } = string.Empty;
// Prix de vente fourni par le fournisseur
public decimal SellingPrice { get; set; }
}
}

View File

@@ -1,21 +1,40 @@
namespace API.DTO.Warehouse.Request;
public class CreateWarehouseDto
namespace API.DTO.Warehouse.Request
{
public string Name { get; set; }
public int MaxWeight { get; set; }
public int Current { get; set; }
public int MinWeight { get; set; }
public string Adress { get; set; }
public int ZipCode { get; set; }
public string City { get; set; }
// DTO pour créer un entrepôt
public class CreateWarehouseDto
{
// Nom de l'entrepôt
public string Name { get; set; }
// Liste des produits à stocker dans cet entrepôt
public List<CreateWarehouseProductDto>? Products { get; set; }
}
// Poids maximal que l'entrepôt peut contenir
public int MaxWeight { get; set; }
public class CreateWarehouseProductDto
{
public int ProductId { get; set; }
public int Quantity { get; set; }
// Poids actuel stocké
public int Current { get; set; }
// Poids minimal souhaité
public int MinWeight { get; set; }
// Adresse de l'entrepôt
public string Adress { get; set; }
// Code postal
public int ZipCode { get; set; }
// Ville
public string City { get; set; }
// Liste des produits à stocker dans cet entrepôt venant de la classe en dessous
public List<CreateWarehouseProductDto>? Products { get; set; }
}
// DTO pour associer un produit à un entrepôt
public class CreateWarehouseProductDto
{
// Identifiant du produit
public int ProductId { get; set; }
// Quantité du produit dans l'entrepôt
public int Quantity { get; set; }
}
}

View File

@@ -1,21 +1,43 @@
namespace API.DTO.Warehouse.Request;
public class UpdateWarehouseDto
namespace API.DTO.Warehouse.Request
{
public int Id { get; set; }
public string Name { get; set; }
public int MaxWeight { get; set; }
public int Current { get; set; }
public int MinWeight { get; set; }
public string Adress { get; set; }
public int ZipCode { get; set; }
public string City { get; set; }
public List<UpdateWarehouseProductDto>? Products { get; set; }
}
// DTO pour mettre à jour un entrepôt
public class UpdateWarehouseDto
{
// Identifiant de l'entrepôt à mettre à jour
public int Id { get; set; }
public class UpdateWarehouseProductDto
{
public int ProductId { get; set; }
public int Quantity { get; set; }
// Nom de l'entrepôt
public string Name { get; set; }
// Poids maximal que l'entrepôt peut contenir
public int MaxWeight { get; set; }
// Poids actuel stocké
public int Current { get; set; }
// Poids minimal souhaité
public int MinWeight { get; set; }
// Adresse de l'entrepôt
public string Adress { get; set; }
// Code postal
public int ZipCode { get; set; }
// Ville
public string City { get; set; }
// Liste des produits à mettre à jour dans cet entrepôt
public List<UpdateWarehouseProductDto>? Products { get; set; }
}
// DTO pour mettre à jour la quantité d'un produit dans un entrepôt
public class UpdateWarehouseProductDto
{
// Identifiant du produit
public int ProductId { get; set; }
// Nouvelle quantité du produit dans l'entrepôt
public int Quantity { get; set; }
}
}

View File

@@ -1,22 +1,46 @@
namespace API.DTO.Warehouse.Response;
public class GetWarehouseDto
namespace API.DTO.Warehouse.Response
{
public int Id { get; set; }
public string Name { get; set; }
public int MaxWeight { get; set; }
public int Current { get; set; }
public int MinWeight { get; set; }
public string Adress { get; set; }
public int ZipCode { get; set; }
public string City { get; set; }
// DTO pour la lecture d'un entrepôt
public class GetWarehouseDto
{
// Identifiant de l'entrepôt
public int Id { get; set; }
public List<WarehouseProductDto>? Products { get; set; }
}
// Nom de l'entrepôt
public string Name { get; set; }
public class WarehouseProductDto
{
public int ProductId { get; set; }
public string? ProductName { get; set; }
public int Quantity { get; set; }
// Poids maximal que l'entrepôt peut contenir
public int MaxWeight { get; set; }
// Poids actuellement stocké
public int Current { get; set; }
// Poids minimal souhaité
public int MinWeight { get; set; }
// Adresse de l'entrepôt
public string Adress { get; set; }
// Code postal
public int ZipCode { get; set; }
// Ville
public string City { get; set; }
// Liste des produits stockés dans l'entrepôt
public List<WarehouseProductDto>? Products { get; set; }
}
// DTO pour la lecture d'un produit dans un entrepôt
public class WarehouseProductDto
{
// Identifiant du produit
public int ProductId { get; set; }
// Nom du produit
public string? ProductName { get; set; }
// Quantité du produit dans l'entrepôt
public int Quantity { get; set; }
}
}

View File

@@ -1,6 +1,6 @@
using API.DTO.Brand.Request;
using API.DTO.Brand.Response;
using FastEndpoints;
using PyroFetes.DTO.Brand.Request;
namespace PyroFetes.Endpoints.Brand;

View File

@@ -1,6 +1,6 @@
using API.DTO.Brand.Request;
using API.DTO.Brand.Response;
using FastEndpoints;
using PyroFetes.DTO.Brand.Request;
namespace PyroFetes.Endpoints.Brand;
@@ -8,7 +8,7 @@ public class UpdateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
{
public override void Configure()
{
Put("/api/brands");
Put("/api/brands/{Id}");
AllowAnonymous();
}

View File

@@ -1,26 +1,27 @@
using API.DTO.Color.Request;
using API.DTO.Color.Response;
using FastEndpoints;
using PyroFetes;
namespace PyroFetes.Endpoints.Color;
namespace API.Endpoints.Color;
public class CreateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateColorDto, GetColorDto>
public class CreateColorEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateColorDto, GetColorDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateColorDto et l'élement de réponse GetColorDto
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Post("/color/create");
AllowAnonymous();
Post("Api/colors"); //Création d'un endpoint pour créer une couleur avec les données de CreateColorDto
AllowAnonymous(); //Laisser passer les requêtes non authentifiées
}
public override async Task HandleAsync(CreateColorDto req, CancellationToken ct)
public override async Task HandleAsync(CreateColorDto req, CancellationToken ct) //La méthode HandleAsync est appelée lorsqu'une requête est envoyée à l'endpoint
{
Models.Color color = new()
PyroFetes.Models.Color color = new()
{
Label = req.Label,
};
pyrofetesdbcontext.Colors.Add(color);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyroFetesDbContext.Colors.Add(color);
await pyroFetesDbContext.SaveChangesAsync(ct);
Console.WriteLine("Added Color");
GetColorDto responseDto = new()

View File

@@ -12,7 +12,7 @@ public class DeleteColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
{
public override void Configure()
{
Delete("/colors/{@id}", x => new { x.Id });
Delete("Api/colors/{@id}", x => new { x.Id });
AllowAnonymous();
}

View File

@@ -8,7 +8,7 @@ public class GetAllColorsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpo
{
public override void Configure()
{
Get("/colors");
Get("Api/colors");
AllowAnonymous();
}

View File

@@ -13,7 +13,7 @@ public class GetColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<
{
public override void Configure()
{
Get("/colors/{@id}", x => new { x.Id});
Get("Api/colors/{@id}", x => new { x.Id});
AllowAnonymous();
}

View File

@@ -9,7 +9,7 @@ public class UpdateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
{
public override void Configure()
{
Put("/colors/{@id}", x => new { x.Id });
Put("Api/colors/{@id}", x => new { x.Id });
AllowAnonymous();
}

View File

@@ -8,7 +8,7 @@ public class CreateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpo
{
public override void Configure()
{
Post("/effect/create");
Post("Api/effects");
AllowAnonymous();
}

View File

@@ -11,7 +11,7 @@ public class DeleteEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpo
{
public override void Configure()
{
Delete("/effects/{@id}", x => new { x.Id });
Delete("Api/effects/{@id}", x => new { x.Id });
AllowAnonymous();
}

View File

@@ -8,7 +8,7 @@ public class GetAllEffectsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endp
{
public override void Configure()
{
Get("/effects");
Get("Api/effects");
AllowAnonymous();
}

View File

@@ -13,7 +13,7 @@ public class GetEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint
{
public override void Configure()
{
Get("/effect/{@id}", x => new { x.Id });
Get("Api/effects/{@id}", x => new { x.Id });
AllowAnonymous();
}

View File

@@ -9,7 +9,7 @@ public class UpdateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpo
{
public override void Configure()
{
Put("/effect/{@id}", x => new { x.Id });
Put("Api/effects/{@id}", x => new { x.Id });
AllowAnonymous();
}

View File

@@ -0,0 +1,44 @@
using PyroFetes.DTO.Login.Request;
using PyroFetes.DTO.Login.Response;
using PasswordGenerator;
namespace PyroFetes.Endpoints.Login;
using FastEndpoints;
public class CreateLoginEndpoint(PyroFetesDbContext database) : Endpoint<CreateLoginDto, GetLoginDto>
{
public override void Configure()
{
Post("/api/logins");
AllowAnonymous();
}
public override async Task HandleAsync(CreateLoginDto req, CancellationToken ct)
{
string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next();
var login = new Models.Login()
{
Username = req.Username,
FullName = req.FullName,
Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt),
Salt = salt
};
database.Logins.Add(login);
await database.SaveChangesAsync(ct);
// Pour renvoyer une erreur : Send.StringAsync("Le message d'erreur", 400);
GetLoginDto responseDto = new()
{
Id = login.Id,
Username = login.Username,
FullName = login.FullName,
Password = login.Password,
Salt = login.Salt
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,35 @@
using PyroFetes.DTO.Login.Request;
using PyroFetes.DTO.Login.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Login;
public class DeleteLoginRequest
{
public int Id { get; set; }
}
public class DeleteLoginEndpoint(PyroFetesDbContext database) : Endpoint<DeleteLoginRequest>
{
public override void Configure()
{
Delete("/api/logins/{@Id}", x => new {x.Id});
}
public override async Task HandleAsync(DeleteLoginRequest req, CancellationToken ct)
{
var login = await database.Logins.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (login == null)
{
await Send.NotFoundAsync(ct);
return;
}
database.Logins.Remove(login);
await database.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,30 @@
using PyroFetes.DTO.Login.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes;
namespace PyroFetes.Endpoints.Login;
public class GetAllLoginEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetLoginDto>>
{
public override void Configure()
{
Get("/api/logins");
}
public override async Task HandleAsync(CancellationToken ct)
{
var logins = await database.Logins
.Select(login => new GetLoginDto()
{
Id = login.Id,
Username = login.Username,
FullName = login.FullName,
Password = login.Password,
Salt = login.Salt
})
.ToListAsync(ct);
await Send.OkAsync(logins, ct);
}
}

View File

@@ -0,0 +1,41 @@
using PyroFetes.DTO.Login.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Login;
public class GetLoginRequest
{
public int Id { get; set; }
}
public class GetLoginEndpoint(PyroFetesDbContext database) : Endpoint<GetLoginRequest, GetLoginDto>
{
public override void Configure()
{
Get("/api/logins/{@Id}", x => new {x.Id});
}
public override async Task HandleAsync(GetLoginRequest req, CancellationToken ct)
{
var login = await database.Logins
.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (login == null)
{
await Send.NotFoundAsync(ct);
return;
}
GetLoginDto responseDto = new()
{
Id = login.Id,
Username = login.Username,
FullName = login.FullName,
Password = login.Password,
Salt = login.Salt
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,45 @@
using PyroFetes.DTO.Login.Request;
using PyroFetes.DTO.Login.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PasswordGenerator;
namespace PyroFetes.Endpoints.Login;
public class UpdateLoginEndpoint(PyroFetesDbContext database) : Endpoint<UpdateLoginDto, GetLoginDto>
{
public override void Configure()
{
Put("/api/logins/{@Id}", x => new {x.Id});
}
public override async Task HandleAsync(UpdateLoginDto req, CancellationToken ct)
{
var login = await database.Logins.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (login == null)
{
await Send.NotFoundAsync(ct);
return;
}
string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next();
login.Username = req.Username;
login.FullName = req.FullName;
login.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt);
login.Salt = salt;
await database.SaveChangesAsync(ct);
GetLoginDto responseDto = new()
{
Id = login.Id,
Username = login.Username,
FullName = login.FullName,
Password = login.Password,
Salt = login.Salt
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,50 @@
using PyroFetes.DTO.Login.Request;
using FastEndpoints.Security;
using PyroFetes.DTO.Login.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes;
namespace PyroFetes.Endpoints.Login;
public class UserLoginEndpoint(PyroFetesDbContext database) : Endpoint<ConnectLoginDto, GetLoginConnectDto>
{
public override void Configure()
{
Post("/api/login");
AllowAnonymous();
}
public override async Task HandleAsync(ConnectLoginDto req, CancellationToken ct)
{
var login = await database.Logins.SingleOrDefaultAsync(x => x.Username == req.Username, ct);
if (login == null)
{
await Send.UnauthorizedAsync(ct);
return;
}
if (BCrypt.Net.BCrypt.Verify(req.Password + login.Salt, login.Password))
{
var jwtToken = JwtBearer.CreateToken(
o =>
{
o.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong";
o.ExpireAt = DateTime.UtcNow.AddMinutes(15);
if (login.Role != null) o.User.Roles.Add(login.Role);
o.User.Claims.Add(("Username", login.Username)!);
o.User.Claims.Add(("FullName", login.FullName)!);
o.User["UserId"] = "001";
});
GetLoginConnectDto responseDto = new()
{
Token = jwtToken
};
await Send.OkAsync(responseDto, ct);
}
else await Send.UnauthorizedAsync(ct);
}
}

View File

@@ -8,7 +8,7 @@ public class CreateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
{
public override void Configure()
{
Post("/material/create");
Post("Api/materials");
AllowAnonymous();
}

View File

@@ -8,7 +8,7 @@ public class GetAllMaterialsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : En
{
public override void Configure()
{
Get("/material");
Get("Api/materials");
AllowAnonymous();
}

View File

@@ -13,7 +13,7 @@ public class GetMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
{
public override void Configure()
{
Get("/material/{@id}", x => new { x.Id });
Get("Api/materials/{@id}", x => new { x.Id });
AllowAnonymous();
}

View File

@@ -9,7 +9,7 @@ public class UpdateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
{
public override void Configure()
{
Put("/material/{@id}", x => new { x.Id });
Put("Api/materials/{@id}", x => new { x.Id });
AllowAnonymous();
}

View File

@@ -2,8 +2,6 @@
using PyroFetes.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;
@@ -21,14 +19,13 @@ public class CreateProductEndpoint(PyroFetesDbContext db)
{
var product = new Models.Product
{
References = req.References,
Reference = req.References.ToString(),
Name = req.Name!,
Duration = req.Duration,
Caliber = req.Caliber,
ApprovalNumber = req.ApprovalNumber,
Weight = req.Weight,
Nec = req.Nec,
SellingPrice = req.SellingPrice,
Image = req.Image!,
Link = req.Link!,
ProductCategoryId = req.ProductCategoryId,

View File

@@ -1,9 +1,7 @@
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response;
using PyroFetes.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;
@@ -23,20 +21,22 @@ public class GetAllProductsEndpoint(PyroFetesDbContext db)
var products = await db.Products
.Include(p => p.Prices)
.Include(p => p.WarehouseProducts)
.ThenInclude(wp => wp.Warehouse)
.ThenInclude(wp => wp.Warehouse)
.ToListAsync(ct);
var responseDto = products.Select(p => new GetProductDto
{
Id = p.Id,
Reference = p.References,
// Le modèle Product contient "Reference" (string) — pas "References" (int)
Reference = int.TryParse(p.Reference, out var refInt) ? refInt : 0,
Name = p.Name,
Duration = p.Duration,
Caliber = p.Caliber,
ApprovalNumber = p.ApprovalNumber,
Weight = p.Weight,
Nec = p.Nec,
SellingPrice = p.SellingPrice,
// Le prix de vente nest pas dans Product, on le récupère via Prices
SellingPrice = p.Prices.FirstOrDefault()?.SellingPrice ?? 0,
Image = p.Image,
Link = p.Link,
ClassificationId = p.ClassificationId,
@@ -49,7 +49,7 @@ public class GetAllProductsEndpoint(PyroFetesDbContext db)
SellingPrice = pr.SellingPrice
}).ToList(),
// Liste des entrepôts via WarehouseProduct
// Liste des entrepôts liés via WarehouseProduct
Warehouses = p.WarehouseProducts.Select(wp => new GetProductWarehouseDto
{
WarehouseId = wp.WarehouseId,
@@ -60,4 +60,4 @@ public class GetAllProductsEndpoint(PyroFetesDbContext db)
await Send.OkAsync(responseDto, ct);
}
}
}

View File

@@ -1,9 +1,7 @@
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response;
using PyroFetes.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;
@@ -41,14 +39,20 @@ public class GetProductEndpoint(PyroFetesDbContext db)
var responseDto = new GetProductDto
{
Id = product.Id,
Reference = product.References,
// Le modèle Product contient "Reference" (string), pas "References" (int)
Reference = int.TryParse(product.Reference, out var refInt) ? refInt : 0,
Name = product.Name,
Duration = product.Duration,
Caliber = product.Caliber,
ApprovalNumber = product.ApprovalNumber,
Weight = product.Weight,
Nec = product.Nec,
SellingPrice = product.SellingPrice,
// Le prix de vente nest pas dans Product → récupéré via Price
SellingPrice = product.Prices.FirstOrDefault()?.SellingPrice ?? 0,
Image = product.Image,
Link = product.Link,
ClassificationId = product.ClassificationId,
@@ -72,4 +76,4 @@ public class GetProductEndpoint(PyroFetesDbContext db)
await Send.OkAsync(responseDto, ct);
}
}
}

View File

@@ -2,8 +2,6 @@
using PyroFetes.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;
@@ -37,21 +35,19 @@ public class UpdateProductEndpoint(PyroFetesDbContext db)
}
// Mise à jour des propriétés principales du produit
product.References = req.References;
product.Reference = req.References.ToString(); // Converti int → string
product.Name = req.Name;
product.Duration = req.Duration;
product.Caliber = req.Caliber;
product.ApprovalNumber = req.ApprovalNumber;
product.Weight = req.Weight;
product.Nec = req.Nec;
product.SellingPrice = req.SellingPrice;
product.Image = req.Image;
product.Link = req.Link;
product.ClassificationId = req.ClassificationId;
product.ProductCategoryId = req.ProductCategoryId;
// Mise à jour des prix fournisseurs associés
// On supprime les anciens enregistrements pour les remplacer
db.Prices.RemoveRange(product.Prices);
foreach (var s in req.Suppliers)
{
@@ -64,7 +60,6 @@ public class UpdateProductEndpoint(PyroFetesDbContext db)
}
// Mise à jour des entrepôts associés
// On supprime les anciens liens avant d'ajouter les nouveaux
db.WarehouseProducts.RemoveRange(product.WarehouseProducts);
foreach (var w in req.Warehouses)
{
@@ -76,44 +71,41 @@ public class UpdateProductEndpoint(PyroFetesDbContext db)
});
}
// Sauvegarde des modifications dans la base de données
await db.SaveChangesAsync(ct);
// Construction de la réponse renvoyée au client
// On reconstruit les listes Suppliers et Warehouses au bon format de DTO
var response = new GetProductDto
{
Id = product.Id,
Reference = req.References,
Reference = req.References, // DTO garde int pour cohérence
Name = req.Name,
Duration = req.Duration,
Caliber = req.Caliber,
ApprovalNumber = req.ApprovalNumber,
Weight = req.Weight,
Nec = req.Nec,
SellingPrice = req.SellingPrice,
// Le prix de vente est pris depuis Prices
SellingPrice = req.Suppliers.FirstOrDefault()?.SellingPrice ?? 0,
Image = req.Image,
Link = req.Link,
ClassificationId = req.ClassificationId,
ProductCategoryId = req.ProductCategoryId,
// Mapping des fournisseurs pour la réponse
Suppliers = req.Suppliers.Select(s => new ProductSupplierPriceDto
{
SupplierId = s.SupplierId,
SellingPrice = s.SellingPrice
}).ToList(),
// Mapping des entrepôts pour la réponse
Warehouses = req.Warehouses.Select(w => new GetProductWarehouseDto
{
WarehouseId = w.WarehouseId,
Quantity = w.Quantity,
WarehouseName = db.Warehouses.FirstOrDefault(x => x.Id == w.WarehouseId)?.Name ?? string.Empty
WarehouseName = db.Warehouses
.FirstOrDefault(x => x.Id == w.WarehouseId)?.Name ?? string.Empty
}).ToList()
};
// Envoi de la réponse HTTP 200 avec les données du produit mis à jour
await Send.OkAsync(response, ct);
}
}

View File

@@ -13,11 +13,9 @@ public class DeleteWarehouseEndpoint(PyroFetesDbContext db) : Endpoint<DeleteWar
{
public override void Configure()
{
// Lannotation correcte du paramètre est {id}, pas {@id}
Delete("/api/warehouse/{@id}", x => new { x.Id });
Delete("/api/warehouse/{id}");
AllowAnonymous();
}
public override async Task HandleAsync(DeleteWarehouseRequest req, CancellationToken ct)
{
// On charge aussi les WarehouseProducts liés pour les supprimer proprement

View File

@@ -16,7 +16,7 @@ public class GetWarehouseEndpoint(PyroFetesDbContext db)
public override void Configure()
{
// Pas de "@id" ici, juste {id}
Get("/api/warehouses/{@id}", x => new { x.Id });
Get("/api/warehouses/{Id}");
AllowAnonymous();
}

View File

@@ -12,7 +12,7 @@ public class UpdateWarehouseEndpoint(PyroFetesDbContext db)
public override void Configure()
{
// Utilise {id} plutôt que {@id}
Put("/api/warehouses/{@id}", x => new { x.Id });
Put("/api/warehouses/{Id}");
AllowAnonymous();
}

13
PyroFetes/Models/Login.cs Normal file
View File

@@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace PyroFetes.Models;
public class Login
{
[Key] public int Id { get; set; }
[Required, MaxLength(100)] public string? Username { get; set; }
[Required, MaxLength(200)] public string? FullName { get; set; }
[Required, Length(60, 60)] public string? Password { get; set; }
[Required, Length(24, 24)] public string? Salt { get; set; }
[Required, MaxLength(100)] public string? Role { get; set; }
}

View File

@@ -5,14 +5,13 @@ namespace PyroFetes.Models
public class Product
{
[Key] public int Id { get; set; }
[Required] public int References { get; set; }
[Required, MaxLength(20)] public string? Reference { get; set; }
[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 decimal Weight { get; set; }
[Required] public decimal Nec { get; set; }
[Required] public decimal SellingPrice { get; set; }
[Required] public string? Image { get; set; }
[Required, MaxLength(200)] public string? Link { get; set; }
[Required] public int MinimalQuantity { get; set; }

View File

@@ -2,18 +2,27 @@ using API;
using FastEndpoints;
using FastEndpoints.Swagger;
using PyroFetes;
using FastEndpoints.Security;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
builder.Services.AddFastEndpoints().SwaggerDocument();
builder.Services
.AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong")
.AddAuthorization()
.AddFastEndpoints()
.SwaggerDocument();
// On ajoute ici la configuration de la base de données
builder.Services.AddDbContext<PyroFetesDbContext>();
// On construit l'application en lui donnant vie
WebApplication app = builder.Build();
app.UseFastEndpoints().UseSwaggerGen();
app.UseAuthentication()
.UseAuthorization()
.UseFastEndpoints()
.UseSwaggerGen();
app.UseHttpsRedirection();

View File

@@ -7,16 +7,19 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="FastEndpoints" Version="7.0.1" />
<PackageReference Include="FastEndpoints.Security" Version="7.0.1" />
<PackageReference Include="FastEndpoints.Swagger" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.20">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.20" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
<PackageReference Include="PasswordGenerator" Version="2.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
</Project>

View File

@@ -49,6 +49,7 @@ public class PyroFetesDbContext : DbContext
public DbSet<User> Users { get; set; }
public DbSet<Warehouse> Warehouses { get; set; }
public DbSet<WarehouseProduct> WarehouseProducts { get; set; }
public DbSet<Login> Logins { get; set; }
// Database configuration
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)