24 Commits

Author SHA1 Message Date
3c32baac57 commentaire endpoint 2025-11-05 22:38:55 +01:00
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
0e74cb40f5 Merge branch 'feature/gabriel' into develop 2025-10-09 17:36:59 +02:00
91b4aca2fa 17:17 09/10 2025-10-09 17:17:42 +02:00
1734ec0219 le reste 2025-10-09 17:03:05 +02:00
7a8daa6ab8 le sln 2025-10-09 17:01:54 +02:00
8f4171a045 09/10 2025-10-09 16:55:29 +02:00
8a8a47c99c Initial commit 2025-10-09 16:52:35 +02:00
bb5dd63da2 MAJ Coquille 2025-10-09 16:18:21 +02:00
c5805d979b MaJ des .txt en .cs 2025-10-09 16:09:30 +02:00
44da6ed371 Maj 2025-10-09 15:50:02 +02:00
08bf910437 Maj Warehouse et Supplier 2025-10-09 15:39:10 +02:00
d1fa3aca68 MAJ Mathilde 2025-10-09 15:16:08 +02:00
120 changed files with 2404 additions and 1221 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

@@ -1,21 +1,50 @@
using PyroFetes.Models;
using PyroFetes.DTO.Product.Request;
namespace PyroFetes.DTO.Product.Request;
public class CreateProductDto
namespace PyroFetes.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 int ClassificationId { get; set;}
public int ProductCategoryId { get; set; }
// 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; }
// 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 venant du DTO ProductSupplierPriceDto
public List<ProductSupplierPriceDto>? Suppliers { get; set; }
// Liste des entrepôts liés au produit venant du DTO CreateProductWarehouseDto
public List<CreateProductWarehouseDto>? Warehouses { get; set; }
}
}

View File

@@ -1,20 +1,53 @@
using PyroFetes.Models;
using PyroFetes.DTO.Product.Request;
namespace PyroFetes.DTO.Product.Request;
public class UpdateProductDto
namespace PyroFetes.DTO.Product.Request
{
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; }
// 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 venant du DTO ProductSupplierPriceDto
public List<ProductSupplierPriceDto> Suppliers { get; set; } = new();
// Liste des entrepôts associés venant du DTO UpdateProductWarehouseDto
public List<UpdateProductWarehouseDto> Warehouses { get; set; } = new();
}
}

View File

@@ -1,23 +1,54 @@
using PyroFetes.Models;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response;
namespace PyroFetes.DTO.Product.Response;
public class GetProductDto
namespace PyroFetes.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 string? ClassificationLabel { get; set; }
public int ProductCategoryId { get; set; }
public string? ProductCategoryLabel { get; set; }
// 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 venant du DTO ProductSupplierPriceDto
public List<ProductSupplierPriceDto> Suppliers { get; set; } = new();
// 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

@@ -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
}
}

View File

@@ -0,0 +1,18 @@
namespace PyroFetes.DTO.Product.Response
{
// 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

@@ -0,0 +1,28 @@
namespace PyroFetes.DTO.Product.Request
{
// 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

@@ -0,0 +1,18 @@
namespace PyroFetes.DTO.Product.Response
{
// 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,11 +1,37 @@
namespace API.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; }
// 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 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,12 +1,30 @@
namespace API.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; }
// 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,12 +1,45 @@
namespace API.DTO.Supplier.Response;
using PyroFetes.DTO.Supplier.Request;
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; }
// Nom du fournisseur
public string Name { 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,12 +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; }
// 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 à 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,13 +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; }
// DTO pour mettre à jour un entrepôt
public class UpdateWarehouseDto
{
// Identifiant de l'entrepôt à mettre à jour
public int Id { 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,13 +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; }
// Nom de l'entrepôt
public string Name { 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,35 +1,35 @@
using API.DTO.Brand.Request;
using API.DTO.Brand.Response;
using FastEndpoints;
using PyroFetes.DTO.Brand.Request;
namespace PyroFetes.Endpoints.Brand;
public class CreateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateBrandDto, GetBrandDto>
public class CreateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateBrandDto, GetBrandDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateBrandDto et l'élement de réponse GetBrandDto
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Post("/api/brands");
AllowAnonymous();
Post("/api/brands"); //Créer une marque
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CreateBrandDto req, CancellationToken ct)
public override async Task HandleAsync(CreateBrandDto req, CancellationToken ct)
{
Models.Brand brand = new ()
Models.Brand brand = new () //Création d'un nom rentré par l'utilisateur
{
Name = req.Name
};
pyrofetesdbcontext.Brands.Add(brand);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Brands.Add(brand); //Ajout de la marque à la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde de la marque dans la bdd
Console.WriteLine("Marque créé avec succès !");
GetBrandDto responseDto = new ()
GetBrandDto responseDto = new () //Renvoie le nom
{
Name = req.Name
Name = req.Name
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Réponse au client
}
}

View File

@@ -5,34 +5,34 @@ namespace PyroFetes.Endpoints.Brand;
public class DeleteBrandRequest
{
public int Id { get; set; }
public int Id { get; set; } //Création d'un Id
}
public class DeleteBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteBrandRequest>
public class DeleteBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteBrandRequest> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête DeleteBrandDto.
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Delete("/api/brands/{@id}", x => new { x.Id });
AllowAnonymous();
Delete("/api/brands/{@id}", x => new { x.Id }); //Supprime une marque
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(DeleteBrandRequest req, CancellationToken ct)
{
Models.Brand? brandToDelete = await pyrofetesdbcontext
.Brands
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
Models.Brand? brandToDelete = await pyrofetesdbcontext //Récupère une marque dans la bdd et le stocke dans brandToDelete
.Brands //Recherche la couleur dans la table Colors
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); //Recherche une couleur dont l'id correspond à req.Id
if (brandToDelete == null)
{
Console.WriteLine($"Aucune marque avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
pyrofetesdbcontext.Brands.Remove(brandToDelete);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Brands.Remove(brandToDelete); //Supprime la marque de la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde de la marque dans la bdd
await Send.NoContentAsync(ct);
await Send.NoContentAsync(ct); //Renvoie une réponse réussite 204
}
}

View File

@@ -8,21 +8,21 @@ public class GetAllBrandsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpo
{
public override void Configure()
{
Get("/api/brands");
AllowAnonymous();
Get("/api/brands"); //Endpoint qui affiche toutes les marques
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetBrandDto> responseDto = await pyrofetesdbcontext.Brands
.Select(a => new GetBrandDto
List<GetBrandDto> responseDto = await pyrofetesdbcontext.Brands //Création d'une liste qui récupère toutes les marques dans la bdd
.Select(a => new GetBrandDto //Sélectionne dans la liste chaque marque
{
Id = a.Id,
Name = a.Name,
Id = a.Id, //Affiche l'id
Name = a.Name, //Affiche le nom
}
).ToListAsync(ct);
).ToListAsync(ct); //Retourne la liste de marque
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -13,30 +13,30 @@ public class GetBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<G
{
public override void Configure()
{
Get("/api/brands/{@id}", x => new { x.Id });
AllowAnonymous();
Get("/api/brands/{@id}", x => new { x.Id }); //endpoint qui affiche la marque en fonction de l'id
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(GetBrandRequest req, CancellationToken ct)
{
Models.Brand? brand = await pyrofetesdbcontext
.Brands
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
Models.Brand? brand = await pyrofetesdbcontext //Récupère la table marque dans la bdd
.Brands
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); //récupère l'id
if (brand == null)
{
Console.WriteLine($"Aucune marque avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
GetBrandDto responseDto = new()
GetBrandDto responseDto = new() //renvoie l'id et le nom
{
Id = req.Id,
Name = brand.Name
Id = req.Id, //Affiche l'id
Name = brand.Name //Affiche le nom
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

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,27 +8,27 @@ public class UpdateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
{
public override void Configure()
{
Post("/api/brands");
AllowAnonymous();
Put("/api/brands/{Id}"); //Met à jour la marque en fonction de l'id
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(UpdateBrandDto req, CancellationToken ct)
{
Models.Brand brand = new()
Models.Brand brand = new() //Met à jour la marque
{
Name = req.Name
};
pyrofetesdbcontext.Add(brand);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Add(brand); //ajoute la marque dans la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements
GetBrandDto response = new()
GetBrandDto response = new() //renvoie l'id et le nom
{
Id = req.Id,
Name = req.Name
};
await Send.OkAsync(response, ct);
await Send.OkAsync(response, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -4,32 +4,32 @@ using FastEndpoints;
namespace PyroFetes.Endpoints.Classification;
public class CreateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateClassificationDto, GetClassificationDto>
public class CreateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateClassificationDto, GetClassificationDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateClassificationDto et l'élement de réponse GetClassificationDto
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Post("/api/classifications");
AllowAnonymous();
Post("/api/classifications"); //Créer une classification
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CreateClassificationDto req, CancellationToken ct)
{
Models.Classification classification = new ()
Models.Classification classification = new () //Création d'un label rentré par l'utilisateur
{
Label = req.Label
};
pyrofetesdbcontext.Classifications.Add(classification);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Classifications.Add(classification); //Ajout de la classification à la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde de la classification dans la bdd
Console.WriteLine("Classification créée avec succès !");
GetClassificationDto responseDto = new ()
GetClassificationDto responseDto = new () //Renvoie le label de la classification
{
Label = req.Label
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Réponse au client
}
}

View File

@@ -12,27 +12,27 @@ public class DeleteClassificationEndpoint(PyroFetesDbContext libraryDbContext) :
{
public override void Configure()
{
Delete("/api/classifications/{@id}", x => new { x.Id });
AllowAnonymous();
Delete("/api/classifications/{@id}", x => new { x.Id }); //Supprime une classification en fonction de l'id
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(DeleteClassificationRequest req, CancellationToken ct)
{
Models.Classification? classificationToDelete = await libraryDbContext
.Classifications
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
Models.Classification? classificationToDelete = await libraryDbContext //Récupère une classification dans la bdd et le stocke dans classificationToDelete
.Classifications //Recherche la classification dans la table Classifications
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); //Recherche une classification dont l'id correspond à req.Id
if (classificationToDelete == null)
{
Console.WriteLine($"Aucune classification avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
libraryDbContext.Classifications.Remove(classificationToDelete);
await libraryDbContext.SaveChangesAsync(ct);
libraryDbContext.Classifications.Remove(classificationToDelete); //Supprime la classification dans la bdd
await libraryDbContext.SaveChangesAsync(ct); //Sauvegarde de la classification dans la bdd
await Send.NoContentAsync(ct);
await Send.NoContentAsync(ct); //Renvoie une réponse réussite 204
}
}

View File

@@ -8,21 +8,21 @@ public class GetAllClassificationsEndpoint(PyroFetesDbContext pyrofetesdbcontext
{
public override void Configure()
{
Get("/api/classifications");
AllowAnonymous();
Get("/api/classifications"); //Endpoint qui affiche toutes les classifications
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetClassificationDto> responseDto = await pyrofetesdbcontext.Classifications
.Select(a => new GetClassificationDto
List<GetClassificationDto> responseDto = await pyrofetesdbcontext.Classifications //Création d'une liste qui récupère toutes les classifications dans la bdd
.Select(a => new GetClassificationDto //Sélectionne dans la liste chaque classification
{
Id = a.Id,
Label = a.Label,
Id = a.Id, //Récupère l'id
Label = a.Label, //Récupère le label
}
).ToListAsync(ct);
).ToListAsync(ct); //Retourne la liste de classification
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -13,30 +13,30 @@ public class GetClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) :E
{
public override void Configure()
{
Get("/api/classifications/{@id}", x => new { x.Id });
AllowAnonymous();
Get("/api/classifications/{@id}", x => new { x.Id }); //endpoint qui affiche la classification en fonction de l'id
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(GetClassificationRequest req, CancellationToken ct)
{
Models.Classification? classification = await pyrofetesdbcontext
Models.Classification? classification = await pyrofetesdbcontext //Récupère la table marque dans la bdd
.Classifications
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); //récupère l'id
if (classification == null)
{
Console.WriteLine($"Aucune classification avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
GetClassificationDto responseDto = new()
{
Id = req.Id,
Label = classification.Label
Id = req.Id, //Affiche l'id
Label = classification.Label //Affiche le nom
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -8,27 +8,27 @@ public class UpdateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext)
{
public override void Configure()
{
Post("/api/classifications");
AllowAnonymous();
Put("/api/classifications"); //Met à jour la classification en fonction de l'id
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(UpdateClassificationDto req, CancellationToken ct)
{
Models.Classification classification = new()
Models.Classification classification = new() //Met à jour la classification
{
Label = req.Label
};
pyrofetesdbcontext.Add(classification);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Add(classification); //ajoute la classification dans la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements
GetClassificationDto response = new()
GetClassificationDto response = new() //renvoie l'id et le nom
{
Id = req.Id,
Label = req.Label
};
await Send.OkAsync(response, ct);
await Send.OkAsync(response, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,35 +0,0 @@
using API.DTO.Color.Request;
using API.DTO.Color.Response;
using FastEndpoints;
namespace API.Endpoints.Color;
public class CreateColorEndpoint(AppDbContext appDbContext) : Endpoint<CreateColorDto, GetColorDto>
{
public override void Configure()
{
Post("/color/create");
AllowAnonymous();
}
public override async Task HandleAsync(CreateColorDto req, CancellationToken ct)
{
Models.Color color = new()
{
Label = req.Label,
};
appDbContext.Colors.Add(color);
await appDbContext.SaveChangesAsync(ct);
Console.WriteLine("Added Color");
GetColorDto responseDto = new()
{
Id = color.Id,
Label = req.Label,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,36 @@
using API.DTO.Color.Request;
using API.DTO.Color.Response;
using FastEndpoints;
using PyroFetes;
namespace API.Endpoints.Color;
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() //Configuration de l'endpoint
{
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) //La méthode HandleAsync est appelée lorsqu'une requête est envoyée à l'endpoint
{
PyroFetes.Models.Color color = new() //Création d'un label rentré par l'utilisateur
{
Label = req.Label,
};
pyroFetesDbContext.Colors.Add(color);
await pyroFetesDbContext.SaveChangesAsync(ct);
Console.WriteLine("Added Color");
GetColorDto responseDto = new()
{
Id = color.Id,
Label = req.Label,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -1,37 +0,0 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Color;
public class DeleteColorRequest
{
public int Id { get; set; }
}
public class DeleteColorEndpoint(AppDbContext appDbContext) : Endpoint<DeleteColorRequest>
{
public override void Configure()
{
Delete("/colors/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct)
{
Models.Color? colorToDelete = await appDbContext
.Colors
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
if (colorToDelete == null)
{
Console.WriteLine($"Aucune couleur avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
appDbContext.Colors.Remove(colorToDelete);
await appDbContext.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Color;
public class DeleteColorRequest //Création d'une classe DeleteColorRequest
{
public int Id { get; set; } //Création d'un Id
}
public class DeleteColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteColorRequest> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête DeleteColorDto.
{
public override void Configure() //Configuration de l'endpoint
{
Delete("Api/colors/{@id}", x => new { x.Id }); //endpoint qui supprime une couleur grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct) //Méthode asynchrone qui traite la suppression de la couleur
{
Models.Color? colorToDelete = await pyrofetesdbcontext //Récupère une couleur dans la bdd et le stocke dans colorToDelete
.Colors //Recherche la couleur dans la table Colors
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); //Recherche une couleur dont l'id correspond à req.Id
if (colorToDelete == null) //Si la couleur n'est pas trouvé
{
Console.WriteLine($"Aucune couleur avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
pyrofetesdbcontext.Colors.Remove(colorToDelete); //Supprime la couleur dans la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
await Send.NoContentAsync(ct); //Renvoie une réponse réussite 204
}
}

View File

@@ -1,26 +0,0 @@
using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Color;
public class GetAllColorsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetColorDto>>
{
public override void Configure()
{
Get("/colors");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetColorDto> responseDto = await appDbContext.Colors
.Select(a => new GetColorDto
{
Id = a.Id,
Label = a.Label,
}
).ToListAsync(ct);
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,26 @@
using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Color;
public class GetAllColorsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetColorDto>>
{
public override void Configure() //Configuration de l'endpoint
{
Get("Api/colors"); //Endpoint qui affiche toutes les couleurs
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetColorDto> responseDto = await pyrofetesdbcontext.Colors //Création d'une liste qui récupère toutes les couleurs dans la bdd
.Select(a => new GetColorDto //Sélectionne dans la liste chaque couleur
{
Id = a.Id, //Récupère l'id
Label = a.Label, //Récupère le label
}
).ToListAsync(ct); //Retourne la liste de couleur
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,42 +0,0 @@
using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Color;
public class GetColorRequest
{
public int Id { get; set; }
}
public class GetColorEndpoint(AppDbContext appDbContext) : Endpoint<GetColorRequest, GetColorDto>
{
public override void Configure()
{
Get("/colors/{@id}", x => new { x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct)
{
Models.Color? color = await appDbContext
.Colors
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
if (color == null)
{
Console.WriteLine("Aucune couleur avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
GetColorDto responseDto = new()
{
Id = color.Id,
Label = color.Label,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,40 @@
using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Color;
public class GetColorRequest
{
public int Id { get; set; }
}
public class GetColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetColorRequest, GetColorDto>
{
public override void Configure()
{
Get("Api/colors/{@id}", x => new { x.Id}); //endpoint qui récupère une couleur grâce à son id
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct) //Méthode asynchrone qui traite la récupération de la couleur
{
Models.Color? color = await pyrofetesdbcontext //Récupère une couleur dans la bdd et le stocke dans color
.Colors //Recherche la couleur dans la table Colors
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); //Recherche une couleur dont l'id correspond à req.Id
if (color == null) //Si la couleur n'est pas trouvé
{
Console.WriteLine("Aucune couleur avec l'ID {req.Id} trouvé."); //Affiche aucune couleur avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
GetColorDto responseDto = new() //Constuire l'objet de réponse pour retourner les informations à l'utilisateur
{
Id = color.Id, //Affiche l'id lors de la réponse
Label = color.Label, //Affiche le label lors de la réponse
};
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,42 +0,0 @@
using API.DTO.Color.Request;
using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Color;
public class UpdateColorEndpoint(AppDbContext appDbContext) : Endpoint<UpdateColorDto, GetColorDto>
{
public override void Configure()
{
Put("/colors/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
{
Models.Color? colorToEdit = await appDbContext
.Colors
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
if (colorToEdit == null)
{
Console.WriteLine("Aucune couleur avec l'id {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
colorToEdit.Label = req.Label;
await appDbContext.SaveChangesAsync(ct);
GetColorDto responseDto = new()
{
Id = req.Id,
Label = req.Label,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,41 @@
using API.DTO.Color.Request;
using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Color;
public class UpdateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateColorDto, GetColorDto>
{
public override void Configure() //Configuration de l'endpoint
{
Put("Api/colors/{@id}", x => new { x.Id }); //Création d'un endpoint qui modifie la couleur grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
{
Models.Color? colorToEdit = await pyrofetesdbcontext //Récupère une couleur dans la bdd et le stocke dans colorToEdit
.Colors //Recherche la couleur dans la table Colors
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); //Recherche une couleur dont l'id correspond à req.Id
if (colorToEdit == null) //Si la couleur n'est pas trouvé
{
Console.WriteLine("Aucune couleur avec l'id {req.Id} trouvé."); //Afficher aucune couleur avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
colorToEdit.Label = req.Label; //Modification du label
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
GetColorDto responseDto = new() //Constuire l'objet de réponse pour retourner l'id et le label de la nouvelle couleur
{
Id = req.Id, //Affiche l'id
Label = req.Label, //Affiche le label
};
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,34 +0,0 @@
using API.DTO.Effect.Request;
using API.DTO.Effect.Response;
using FastEndpoints;
namespace API.Endpoints.Effect;
public class CreateEffectEndpoint(AppDbContext appDbContext) : Endpoint<CreateEffectDto, GetEffectDto>
{
public override void Configure()
{
Post("/effect/create");
AllowAnonymous();
}
public override async Task HandleAsync(CreateEffectDto req, CancellationToken ct)
{
Models.Effect effect = new()
{
Label = req.Label,
};
appDbContext.Effects.Add(effect);
await appDbContext.SaveChangesAsync(ct);
Console.WriteLine("Effect added");
GetEffectDto responseDto = new()
{
Id = effect.Id,
Label = req.Label,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,34 @@
using API.DTO.Effect.Request;
using API.DTO.Effect.Response;
using FastEndpoints;
namespace PyroFetes.Endpoints.Effect;
public class CreateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateEffectDto, GetEffectDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateEffectDto et l'élement de réponse GetEffectDto
{
public override void Configure() //Configuration de l'endpoint
{
Post("Api/effects"); //Créer un effet
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CreateEffectDto req, CancellationToken ct)
{
Models.Effect effect = new() //Création d'un label rentré par l'utilisateur
{
Label = req.Label,
};
pyrofetesdbcontext.Effects.Add(effect); //Ajoute effect à la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
Console.WriteLine("Effect added"); //Affiche Effect added si réussi
GetEffectDto responseDto = new() //Constuire l'objet de réponse pour retourner id et label à l'utilisateur
{
Id = effect.Id, //Affiche l'id lors de la réponse
Label = req.Label, //Affiche le label lors de la réponse
};
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,36 +0,0 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Effect;
public class DeleteEffectRequest
{
public int Id { get; set; }
}
public class DeleteEffectEndpoint(AppDbContext appDbContext) : Endpoint<DeleteEffectRequest>
{
public override void Configure()
{
Delete("/effects/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct)
{
Models.Effect? effectToDelete = await appDbContext
.Effects
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
if (effectToDelete == null)
{
Console.WriteLine($"Aucun effet avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
appDbContext.Effects.Remove(effectToDelete);
await appDbContext.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Effect;
public class DeleteEffectRequest
{
public int Id { get; set; }
}
public class DeleteEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteEffectRequest>
{
public override void Configure() //Configuration de l'endpoint
{
Delete("Api/effects/{@id}", x => new { x.Id }); //Création d'un endpoint qui supprime un effet grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct) //Méthode asynchrone qui traite la suppression de l'effet
{
Models.Effect? effectToDelete = await pyrofetesdbcontext //Récupère un effet dans la bdd et le stocke dans effectToDelete
.Effects //Recherche la couleur dans la table Colors
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); //Recherche un effet dont l'id correspond à req.Id
if (effectToDelete == null) //Si l'effet n'est pas trouvé
{
Console.WriteLine($"Aucun effet avec l'ID {req.Id} trouvé."); //Afficher aucun effet avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
pyrofetesdbcontext.Effects.Remove(effectToDelete); //Supprime l'effet dans la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
await Send.NoContentAsync(ct); //Renvoie une réponse réussite 204
}
}

View File

@@ -1,27 +0,0 @@
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Effect;
public class GetAllEffectsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetEffectDto>>
{
public override void Configure()
{
Get("/effects");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetEffectDto> responseDto = await appDbContext.Effects
.Select(a => new GetEffectDto
{
Id = a.Id,
Label = a.Label,
}
).ToListAsync(ct);
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,27 @@
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Effect;
public class GetAllEffectsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetEffectDto>>
{
public override void Configure() //Configuration de l'endpoint
{
Get("Api/effects"); //Création d'un endpoint pour récupérer tous les effets grâce à la liste
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetEffectDto> responseDto = await pyrofetesdbcontext.Effects //Création d'une liste qui récupère tous les effets de la bdd
.Select(a => new GetEffectDto //Sélectionne dans la liste chaque effet
{
Id = a.Id, //Récupère l'id
Label = a.Label, //Récupère le label
}
).ToListAsync(ct); //Retourne la liste de effet
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,42 +0,0 @@
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Effect;
public class GetEffectRequest
{
public int Id { get; set; }
}
public class GetEffectEndpoint(AppDbContext appDbContext) : Endpoint<GetEffectRequest, GetEffectDto>
{
public override void Configure()
{
Get("/effect/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct)
{
Models.Effect? effect = await appDbContext
.Effects
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
if (effect == null)
{
Console.WriteLine("Aucun effet avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
GetEffectDto responseDto = new()
{
Id = effect.Id,
Label = effect.Label,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,41 @@
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Effect;
public class GetEffectRequest
{
public int Id { get; set; }
}
public class GetEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetEffectRequest, GetEffectDto>
{
public override void Configure() //Configuration de l'endpoint
{
Get("Api/effects/{@id}", x => new { x.Id }); //Création d'un endpoint qui récupère un effet grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct) //Méthode asynchrone qui traite la récupération de l'effet
{
Models.Effect? effect = await pyrofetesdbcontext //Récupère un effet dans la bdd et le stocke dans effect
.Effects //Recherche l'effet dans la table Effects
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); //Recherche un effet dont l'id correspond à req.Id
if (effect == null) //Si l'effet n'est pas trouvé
{
Console.WriteLine("Aucun effet avec l'ID {req.Id} trouvé."); //Afficher aucun effet avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
GetEffectDto responseDto = new() //Constuire l'objet de réponse pour retourner id et label à l'utilisateur
{
Id = effect.Id, //Affiche l'id lors de la réponse
Label = effect.Label, //Affiche le label lors de la réponse
};
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,42 +0,0 @@
using API.DTO.Effect.Request;
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Effect;
public class UpdateEffectEndpoint(AppDbContext appDbContext) : Endpoint<UpdateEffectDto, GetEffectDto>
{
public override void Configure()
{
Put("/effect/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct)
{
Models.Effect? effectToEdit = await appDbContext
.Effects
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
if (effectToEdit == null)
{
Console.WriteLine("Aucun effet avec l'id {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
effectToEdit.Label = req.Label;
await appDbContext.SaveChangesAsync(ct);
GetEffectDto responseDto = new()
{
Id = req.Id,
Label = req.Label,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,38 @@
using API.DTO.Effect.Request;
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Effect;
public class UpdateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateEffectDto, GetEffectDto>
{
public override void Configure() //Configuration de l'endpoint
{
Put("Api/effects/{@id}", x => new { x.Id }); //Création d'un endpoint qui modifie un effet grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct)
{
Models.Effect? effectToEdit = await pyrofetesdbcontext //Récupère un effet dans la bdd et le stocke dans effectToEdit
.Effects //Recherche l'effet dans la table Effects
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); //Recherche un effet dont l'id correspond à req.Id
if (effectToEdit == null) //Si l'effet n'est pas trouvé
{
Console.WriteLine($"Aucun effet avec l'id {req.Id} trouvé."); //Afficher qu'aucun effet avec l'id ... n'a été trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
effectToEdit.Label = req.Label; //Modification du label de l'effet
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la base de données
GetEffectDto responseDto = new() //Construire l'objet de réponse pour retourner l'id et le label de l'effet modifié
{
Id = req.Id, //Inclut l'id dans la réponse
Label = req.Label, //Inclut le label dans la réponse
};
await Send.OkAsync(responseDto, ct); //Envoie une réponse 200 OK avec l'objet de réponse
}
}

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> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateLoginDto et l'élement de réponse GetLoginDto
{
public override void Configure() //Configuration de l'endpoint
{
Post("/api/logins"); //Créer un login
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CreateLoginDto req, CancellationToken ct)
{
string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next();
var login = new Models.Login() //Création d'un nom, prénom, mot de passe et un salt rentré par l'utilisateur
{
Username = req.Username,
FullName = req.FullName,
Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt),
Salt = salt
};
database.Logins.Add(login); //Ajout du login à la bdd
await database.SaveChangesAsync(ct); //Sauvegarde du login dans la bdd
// Pour renvoyer une erreur : Send.StringAsync("Le message d'erreur", 400);
GetLoginDto responseDto = new() //renvoie l'id, nom, prénom, mot de passe et un salt
{
Id = login.Id,
Username = login.Username,
FullName = login.FullName,
Password = login.Password,
Salt = login.Salt
};
await Send.OkAsync(responseDto, ct); //Réponse au client
}
}

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

@@ -1,36 +0,0 @@
using API.DTO.Material.Request;
using API.DTO.Material.Response;
using FastEndpoints;
namespace API.Endpoints.Material;
public class CreateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<CreateMaterialDto, GetMaterialDto>
{
public override void Configure()
{
Post("/material/create");
AllowAnonymous();
}
public override async Task HandleAsync(CreateMaterialDto req, CancellationToken ct)
{
Models.Material quantity = new()
{
Name = req.Name,
Quantity = req.Quantity,
WarehouseId = req.WarehouseId,
};
appDbContext.Materials.Add(quantity);
await appDbContext.SaveChangesAsync(ct);
Console.WriteLine("Material added");
GetMaterialDto responseDto = new()
{
Id = quantity.Id,
WarehouseId = quantity.WarehouseId,
Name = req.Name,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,37 @@
using API.DTO.Material.Request;
using API.DTO.Material.Response;
using FastEndpoints;
namespace PyroFetes.Endpoints.Material;
public class CreateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateMaterialDto, GetMaterialDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateMaterialDto et l'élement de réponse GetMaterialDto
{
public override void Configure() //Configuration de l'endpoint
{
Post("Api/materials"); //Créer un matériel
AllowAnonymous();//Autorise l'accès sans authentification
}
public override async Task HandleAsync(CreateMaterialDto req, CancellationToken ct)
{
Models.Material quantity = new() //Création d'un nom, quantité et liaison de l'id de l'entrepôt rentré par l'utilisateur
{
Name = req.Label,
Quantity = req.Quantity,
WarehouseId = req.WarehouseId,
};
pyrofetesdbcontext.Materials.Add(quantity); //Ajoute quantity à la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
Console.WriteLine("Material added"); //Affiche Material Added si réussi
GetMaterialDto responseDto = new() //Constuire l'objet de réponse pour retourner name, quantity et warehouseId à l'utilisateur
{
Id = quantity.Id, //Affiche l'id lors de la réponse
WarehouseId = quantity.WarehouseId, //Affiche le label lors de la réponse
Label = req.Label, //Affiche le label lors de la réponse
};
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,35 +0,0 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
public class DeleteMaterialRequest
{
public int Id { get; set; }
}
public class DeleteMaterialEndpoint(AppDbContext appDbContext) : Endpoint<DeleteMaterialRequest>
{
public override void Configure()
{
Delete("/materials/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct)
{
Models.Material? materialToDelete = await appDbContext
.Materials
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
if (materialToDelete == null)
{
Console.WriteLine($"Aucun matériel avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
appDbContext.Materials.Remove(materialToDelete);
await appDbContext.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,35 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Material;
public class DeleteMaterialRequest //Création d'une classe DeleteMaterialRequest
{
public int Id { get; set; } //Création d'un Id
}
public class DeleteMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteMaterialRequest>
{
public override void Configure() //Configuration de l'endpoint
{
Delete("Api/materials/{@id}", x => new { x.Id }); //Création d'un endpoint qui supprime un matériel grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct) //Méthode asynchrone qui traite la suppression du matériel
{
Models.Material? materialToDelete = await pyrofetesdbcontext //Récupère un matériel dans la bdd et le stocke dans materialToDelete
.Materials //Recherche la couleur dans la table Colors
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct); //Recherche un matériel dont l'id correspond à req.Id
if (materialToDelete == null) //Si le matériel n'est pas trouvé
{
Console.WriteLine($"Aucun matériel avec l'ID {req.Id} trouvé."); //Afficher aucun matériel avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
pyrofetesdbcontext.Materials.Remove(materialToDelete); //Supprime le matériel dans la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
await Send.NoContentAsync(ct); //Renvoie une réponse réussite 204
}
}

View File

@@ -1,28 +0,0 @@
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
public class GetAllMaterialsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetMaterialDto>>
{
public override void Configure()
{
Get("/material");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetMaterialDto> responseDto = await appDbContext.Materials
.Select(a => new GetMaterialDto
{
Id = a.Id,
Name = a.Name,
Quantity = a.Quantity,
WarehouseId = a.WarehouseId,
}
).ToListAsync(ct);
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,28 @@
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Material;
public class GetAllMaterialsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMaterialDto>>
{
public override void Configure() //Configuration de l'endpoint
{
Get("Api/materials"); //Création d'un endpoint pour récupérer tous les matériaux grâce à la liste
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetMaterialDto> responseDto = await pyrofetesdbcontext.Materials //Création d'une liste qui récupère tous les matériaux de la bdd
.Select(a => new GetMaterialDto //Sélectionne dans la liste chaque matériel
{
Id = a.Id, //Récupère l'id
Label = a.Name, //Récupère le label
Quantity = a.Quantity, //Récupère la quantité
WarehouseId = a.WarehouseId, //Récupère l'id de l'entrepot
}
).ToListAsync(ct); //Retourne la liste du matériel
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,43 +0,0 @@
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
public class GetMaterialRequest
{
public int Id { get; set; }
}
public class GetMaterialEndpoint(AppDbContext appDbContext) : Endpoint<GetMaterialRequest, GetMaterialDto>
{
public override void Configure()
{
Get("/material/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
{
Models.Material? material = await appDbContext
.Materials
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
if (material == null)
{
Console.WriteLine("Aucun matériel avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
GetMaterialDto responseDto = new()
{
Id = material.Id,
Name = material.Name,
WarehouseId = material.WarehouseId,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,42 @@
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Material;
public class GetMaterialRequest
{
public int Id { get; set; }
}
public class GetMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetMaterialRequest, GetMaterialDto>
{
public override void Configure() //Configuration de l'endpoint
{
Get("Api/materials/{@id}", x => new { x.Id }); //Création d'un endpoint qui récupère un matériel grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct) //Méthode asynchrone qui traite la récupération du matériel
{
Models.Material? material = await pyrofetesdbcontext //Récupère un matériel dans la bdd et le stocke dans material
.Materials //Recherche le matériel dans la table Materials
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct); //Recherche un matériel dont l'id correspond à req.Id
if (material == null) //Si le matériel n'est pas trouvé
{
Console.WriteLine("Aucun matériel avec l'ID {req.Id} trouvé."); //Afficher aucun matériel avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
GetMaterialDto responseDto = new() //Constuire l'objet de réponse pour retourner id, label et warehouseId à l'utilisateur
{
Id = material.Id, //Affiche l'id lors de la réponse
Label = material.Name, //Affiche le label lors de la réponse
WarehouseId = material.WarehouseId, //Affiche warehouseId lors de la réponse
};
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,43 +0,0 @@
using API.DTO.Material.Request;
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
public class UpdateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<UpdateMaterialDto, GetMaterialDto>
{
public override void Configure()
{
Put("/material/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct)
{
Models.Material? materialToEdit = await appDbContext
.Materials
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
if (materialToEdit == null)
{
Console.WriteLine("Aucun matériel avec l'id {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
materialToEdit.Name = req.Name;
materialToEdit.WarehouseId = req.WarehouseId;
await appDbContext.SaveChangesAsync(ct);
GetMaterialDto responseDto = new()
{
Id = req.Id,
Name = req.Name,
WarehouseId = req.WarehouseId,
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,42 @@
using API.DTO.Material.Request;
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Material;
public class UpdateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateMaterialDto, GetMaterialDto>
{
public override void Configure() //Configuration de l'endpoint
{
Put("Api/materials/{@id}", x => new { x.Id }); //Création d'un endpoint qui modifie le matériel grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct)
{
Models.Material? materialToEdit = await pyrofetesdbcontext //Récupère un matériel dans la bdd et le stocke dans materialToEdit
.Materials //Recherche le matériel dans la table Materials
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);//Recherche un matériel dont l'id correspond à req.Id
if (materialToEdit == null) //Si le matériel n'est pas trouvé
{
Console.WriteLine("Aucun matériel avec l'id {req.Id} trouvé."); //Afficher aucun matériel avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
materialToEdit.Name = req.Label; //Modification du label
materialToEdit.WarehouseId = req.WarehouseId; //Modification de warehouseId
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
GetMaterialDto responseDto = new() //Constuire l'objet de réponse pour retourner l'id, le label et warehouseId du nouveau matériel
{
Id = req.Id, //Affiche l'id
Label = req.Label, //Affiche le label
WarehouseId = req.WarehouseId, //Affiche warehouseId
};
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -4,18 +4,18 @@ using FastEndpoints;
namespace PyroFetes.Endpoints.Movement;
public class CreateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateMovementDto, GetMovementDto>
public class CreateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateMovementDto, GetMovementDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateMovementDto et l'élement de réponse GetMovementDto
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Post("/api/movements");
AllowAnonymous();
Post("/api/movements"); //Créer un mouvement
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CreateMovementDto req, CancellationToken ct)
{
Models.Movement movement = new ()
Models.Movement movement = new () //Création d'une date, d'une date de départ, d'arrivée et d'une quantité rentré par l'utilisateur
{
Date = req.Date,
Start = req.Start,
@@ -23,19 +23,19 @@ public class CreateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
Quantity = req.Quantity
};
pyrofetesdbcontext.Movements.Add(movement);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Movements.Add(movement); //Ajoute movement à la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
Console.WriteLine("Movement créée avec succès !");
Console.WriteLine("Movement créée avec succès !"); //Affiche Movement créée avec succès ! si réussi
GetMovementDto responseDto = new ()
GetMovementDto responseDto = new () //Constuire l'objet de réponse pour retourner les informations à l'utilisateur
{
Date = req.Date,
Start = req.Start,
Arrival = req.Arrival,
Quantity = req.Quantity
Date = req.Date, //Affiche date lors de la réponse
Start = req.Start, //Affiche start lors de la réponse
Arrival = req.Arrival, //Affiche arrival lors de la réponse
Quantity = req.Quantity //Affiche quantity lors de la réponse
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -3,36 +3,36 @@ using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Movement;
public class DeleteMovementRequest
public class DeleteMovementRequest //Création d'une classe DeleteMovementRequest
{
public int Id { get; set; }
public int Id { get; set; } //Création d'un Id
}
public class DeleteMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteMovementRequest>
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Delete("/api/Movements/{@id}", x => new { x.Id });
AllowAnonymous();
Delete("/api/Movements/{@id}", x => new { x.Id }); //Création d'un endpoint qui supprime un mouvement grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(DeleteMovementRequest req, CancellationToken ct)
public override async Task HandleAsync(DeleteMovementRequest req, CancellationToken ct) //Méthode asynchrone qui traite la suppression du mouvement
{
Models.Movement? movementToDelete = await pyrofetesdbcontext
.Movements
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
Models.Movement? movementToDelete = await pyrofetesdbcontext //Récupère un mouvement dans la bdd et le stocke dans movementToDelete
.Movements //Recherche le mouvement dans la table Movements
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);//Recherche une mouvement dont l'id correspond à req.Id
if (movementToDelete == null)
if (movementToDelete == null) //Si le mouvement n'est pas trouvé
{
Console.WriteLine($"Aucune mouvement avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
Console.WriteLine($"Aucune mouvement avec l'ID {req.Id} trouvé."); //Affiche aucun mouvement avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
pyrofetesdbcontext.Movements.Remove(movementToDelete);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Movements.Remove(movementToDelete); //Supprime le mouvement dans la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
await Send.NoContentAsync(ct);
await Send.NoContentAsync(ct); //Renvoie une réponse réussite 204
}
}

View File

@@ -6,26 +6,26 @@ namespace PyroFetes.Endpoints.Movement;
public class GetAllMovementsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMovementDto>>
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Get("/api/movements");
AllowAnonymous();
Get("/api/movements"); //Création d'un endpoint pour récupérer tous les mouvements grâce à la liste
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetMovementDto> responseDto = await pyrofetesdbcontext.Movements
.Select(a => new GetMovementDto
List<GetMovementDto> responseDto = await pyrofetesdbcontext.Movements //Création d'une liste qui récupère tous les mouvements de la bdd
.Select(a => new GetMovementDto //Sélectionne dans la liste chaque mouvement
{
Id = a.Id,
Date = a.Date,
Start = a.Start,
Arrival = a.Arrival,
Quantity = a.Quantity
Id = a.Id, //Récupère l'id
Date = a.Date, //Récupère la date
Start = a.Start, //Récupère start
Arrival = a.Arrival, //Récupère arrival
Quantity = a.Quantity //Récupère quantity
}
).ToListAsync(ct);
).ToListAsync(ct); //Retourne la liste de mouvement
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -11,35 +11,35 @@ public class GetMovementRequest
public class GetMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<GetMovementRequest, GetMovementDto>
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Get("/api/movements/{@id}", x => new { x.Id });
AllowAnonymous();
Get("/api/movements/{@id}", x => new { x.Id }); //Création d'un endpoint qui récupère un mouvement grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(GetMovementRequest req, CancellationToken ct)
public override async Task HandleAsync(GetMovementRequest req, CancellationToken ct) //Méthode asynchrone qui traite la récupération du mouvement
{
Models.Movement? movement = await pyrofetesdbcontext
.Movements
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
Models.Movement? movement = await pyrofetesdbcontext //Récupère un mouvement dans la bdd et le stocke dans movement
.Movements //Recherche la couleur dans la table Movements
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);//Recherche un mouvement dont l'id correspond à req.Id
if (movement == null)
if (movement == null) //Si le mouvement n'est pas trouvé
{
Console.WriteLine($"Aucun mouvement avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
Console.WriteLine($"Aucun mouvement avec l'ID {req.Id} trouvé."); //Affiche aucun mouvement avec l'id ... trouvé
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
GetMovementDto responseDto = new()
GetMovementDto responseDto = new() //Constuire l'objet de réponse pour retourner les informations à l'utilisateur
{
Id = req.Id,
Date = movement.Date,
Start = movement.Start,
Arrival = movement.Arrival,
Quantity = movement.Quantity
Id = req.Id, //Affiche l'id lors de la réponse
Date = movement.Date, //Affiche date lors de la réponse
Start = movement.Start, //Affiche start lors de la réponse
Arrival = movement.Arrival, //Affiche arrival lors de la réponse
Quantity = movement.Quantity //Affiche quantity lors de la réponse
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -6,26 +6,26 @@ namespace PyroFetes.Endpoints.Movement;
public class UpdateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateMovementDto, GetMovementDto>
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Post("/api/movements");
AllowAnonymous();
Put("/api/movements"); //Création d'un endpoint qui modifie le mouvement grâce à son id
AllowAnonymous(); //Ignorer les requêtes non authentifiées
}
public override async Task HandleAsync(UpdateMovementDto req, CancellationToken ct)
{
Models.Movement movement = new()
Models.Movement movement = new()
{
Date = req.Date,
Start = req.Start,
Arrival = req.Arrival,
Quantity = req.Quantity
};
pyrofetesdbcontext.Add(movement);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Add(movement); //Modification du mouvement
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements effectués dans la bdd
GetMovementDto response = new()
GetMovementDto response = new() //Constuire l'objet de réponse pour retourner les informations du mouvement
{
Id = req.Id,
Date = req.Date,
@@ -34,7 +34,7 @@ public class UpdateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
Quantity = req.Quantity
};
await Send.OkAsync(response, ct);
await Send.OkAsync(response, ct); //Envoie de la réponse réussite 200 au client
}
}

View File

@@ -1,41 +1,78 @@
using FastEndpoints;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product;
public class CreateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateProductDto, GetProductDto>
public class CreateProductEndpoint(PyroFetesDbContext db)
: Endpoint<CreateProductDto, GetProductDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateProductDto et l'élement de réponse GetProductDto
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Post("/api/products");
AllowAnonymous();
Post("/api/products"); //Créer un produit
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CreateProductDto req, CancellationToken ct)
{
Models.Product product = new ()
var product = new Models.Product //Création d'un nom, référence, durée, calibre, numéro d'aprovisionnement, poids, nec, image, lien, liaison de la catégorie du produit et de la classification rentré par l'utilisateur
{
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,
ClassificationId = req.ClassificationId
};
pyrofetesdbcontext.Products.Add(product);
await pyrofetesdbcontext.SaveChangesAsync(ct);
Console.WriteLine("Product créé avec succès !");
GetProductDto responseDto = new ()
db.Products.Add(product); //Ajout du produit à la bdd
await db.SaveChangesAsync(ct); //Sauvegarde du produit dans la bdd
// Ajout des fournisseurs liés
if (req.Suppliers is not null && req.Suppliers.Any())
{
foreach (var s in req.Suppliers)
{
var price = new Price
{
ProductId = product.Id,
SupplierId = s.SupplierId,
SellingPrice = s.SellingPrice
};
db.Prices.Add(price); //Ajout du prix à la bdd
}
await db.SaveChangesAsync(ct); //Sauvegarde du produit dans la bdd
}
// Ajout des entrepôts liés
if (req.Warehouses is not null && req.Warehouses.Any())
{
foreach (var w in req.Warehouses)
{
var exists = await db.Warehouses.AnyAsync(x => x.Id == w.WarehouseId, ct);
if (!exists)
continue; // sécurité : on ignore les warehouses inexistants
var warehouseProduct = new WarehouseProduct
{
ProductId = product.Id,
WarehouseId = w.WarehouseId,
Quantity = w.Quantity
};
db.WarehouseProducts.Add(warehouseProduct); //Ajout du produit de l'entrepot à la bdd
}
await db.SaveChangesAsync(ct); //Sauvegarde du produit de l'entrepot dans la bdd
}
// Construction de la réponse
var response = new GetProductDto
{
Id = product.Id,
Reference = req.References,
@@ -49,9 +86,20 @@ public class CreateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endp
Image = req.Image,
Link = req.Link,
ProductCategoryId = req.ProductCategoryId,
ClassificationId = req.ClassificationId
ClassificationId = req.ClassificationId,
Suppliers = req.Suppliers?.Select(s => new ProductSupplierPriceDto
{
SupplierId = s.SupplierId,
SellingPrice = s.SellingPrice
}).ToList() ?? new(),
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
}).ToList() ?? new()
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(response, ct); //Réponse au client
}
}
}

View File

@@ -1,37 +1,59 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product;
public class DeleteProductRequest
{
public int Id { get; set; }
public int Id { get; set; } //Création d'un Id
}
public class DeleteProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteProductRequest>
public class DeleteProductEndpoint(PyroFetesDbContext db) : Endpoint<DeleteProductRequest>
{
public override void Configure()
{
Delete("/api/products/{@id}", x => new { x.Id });
AllowAnonymous();
Delete("/api/products/{@id}", x => new { x.Id }); //endpoint qui supprime un produit grâce à son id
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(DeleteProductRequest req, CancellationToken ct)
{
Models.Product? productToDelete = await pyrofetesdbcontext
.Products
.SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct);
// Récupérer le produit
var productToDelete = await db.Products
.SingleOrDefaultAsync(p => p.Id == req.Id, ct);
if (productToDelete == null)
if (productToDelete is null)
{
Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
await Send.NotFoundAsync(ct); //Renvoie une erreur 404
return; //Arrêt de la méthode
}
pyrofetesdbcontext.Products.Remove(productToDelete);
await pyrofetesdbcontext.SaveChangesAsync(ct);
// Supprimer les liaisons Price
var relatedPrices = await db.Prices
.Where(p => p.ProductId == req.Id)
.ToListAsync(ct);
if (relatedPrices.Any())
{
db.Prices.RemoveRange(relatedPrices);
}
await Send.NoContentAsync(ct);
// Supprimer les liaisons WarehouseProduct
var relatedWarehouseProducts = await db.WarehouseProducts
.Where(wp => wp.ProductId == req.Id)
.ToListAsync(ct);
if (relatedWarehouseProducts.Any())
{
db.WarehouseProducts.RemoveRange(relatedWarehouseProducts);
}
// Supprimer le produit
db.Products.Remove(productToDelete);
await db.SaveChangesAsync(ct);
Console.WriteLine($"Produit {req.Id}, ses prix et ses entrepôts liés ont été supprimés avec succès.");
await Send.NoContentAsync(ct); //Renvoie une réponse réussite 204
}
}

View File

@@ -1,10 +1,13 @@
using FastEndpoints;
using PyroFetes.DTO.Product.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Response;
using PyroFetes.DTO.Product.Request;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product;
public class GetAllProductsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetProductDto>>
public class GetAllProductsEndpoint(PyroFetesDbContext db)
: EndpointWithoutRequest<List<GetProductDto>>
{
public override void Configure()
{
@@ -14,26 +17,46 @@ public class GetAllProductsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : End
public override async Task HandleAsync(CancellationToken ct)
{
List<GetProductDto> responseDto = await pyrofetesdbcontext.Products
.Select(p => new GetProductDto()
{
Id = p.Id,
Reference = p.References,
Name = p.Name,
Duration = p.Duration,
Caliber = p.Caliber,
ApprovalNumber = p.ApprovalNumber,
Weight = p.Weight,
Nec = p.Nec,
SellingPrice = p.SellingPrice,
Image = p.Image,
Link = p.Link,
ClassificationId = p.ClassificationId,
ClassificationLabel = p.Classification!.Label,
ProductCategoryId = p.ProductCategoryId,
ProductCategoryLabel = p.ProductCategory!.Label,
}
).ToListAsync(ct);
// Inclure toutes les relations nécessaires : Prices + WarehouseProducts + Warehouse
var products = await db.Products
.Include(p => p.Prices)
.Include(p => p.WarehouseProducts)
.ThenInclude(wp => wp.Warehouse)
.ToListAsync(ct);
var responseDto = products.Select(p => new GetProductDto
{
Id = p.Id,
// 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,
// 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,
ProductCategoryId = p.ProductCategoryId,
// Liste des fournisseurs liés via Price
Suppliers = p.Prices.Select(pr => new ProductSupplierPriceDto
{
SupplierId = pr.SupplierId,
SellingPrice = pr.SellingPrice
}).ToList(),
// Liste des entrepôts liés via WarehouseProduct
Warehouses = p.WarehouseProducts.Select(wp => new GetProductWarehouseDto
{
WarehouseId = wp.WarehouseId,
WarehouseName = wp.Warehouse?.Name ?? string.Empty,
Quantity = wp.Quantity
}).ToList()
}).ToList();
await Send.OkAsync(responseDto, ct);
}

View File

@@ -1,6 +1,8 @@
using FastEndpoints;
using PyroFetes.DTO.Product.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Response;
using PyroFetes.DTO.Product.Request;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product;
@@ -9,20 +11,23 @@ public class GetProductRequest
public int Id { get; set; }
}
public class GetProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<GetProductRequest, GetProductDto>
public class GetProductEndpoint(PyroFetesDbContext db)
: Endpoint<GetProductRequest, GetProductDto>
{
public override void Configure()
{
Get("/api/product/{@id}", x => new { x.Id });
Get("/api/products/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetProductRequest req, CancellationToken ct)
{
Models.Product? product = await pyrofetesdbcontext
.Products.Include(product => product.Classification).Include(product => product.ProductCategory)
.SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct);
// Inclure toutes les relations : Prices + WarehouseProducts + Warehouse
var product = await db.Products
.Include(p => p.Prices)
.Include(p => p.WarehouseProducts)
.ThenInclude(wp => wp.Warehouse)
.SingleOrDefaultAsync(p => p.Id == req.Id, ct);
if (product == null)
{
@@ -31,23 +36,42 @@ public class GetProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint
return;
}
GetProductDto responseDto = new()
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,
ClassificationLabel = product.Classification!.Label,
ProductCategoryId = product.ProductCategoryId,
ProductCategoryLabel = product.ProductCategory!.Label,
ProductCategoryId = product.ProductCategoryId,
// Fournisseurs liés via Price
Suppliers = product.Prices.Select(pr => new ProductSupplierPriceDto
{
SupplierId = pr.SupplierId,
SellingPrice = pr.SellingPrice
}).ToList(),
// Entrepôts liés via WarehouseProduct
Warehouses = product.WarehouseProducts.Select(wp => new GetProductWarehouseDto
{
WarehouseId = wp.WarehouseId,
WarehouseName = wp.Warehouse?.Name ?? string.Empty,
Quantity = wp.Quantity
}).ToList()
};
await Send.OkAsync(responseDto, ct);

View File

@@ -1,58 +1,111 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.Product;
public class UpdateProductEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<UpdateProductDto, GetProductDto>
// Endpoint permettant de mettre à jour un produit existant
public class UpdateProductEndpoint(PyroFetesDbContext db)
: Endpoint<UpdateProductDto, GetProductDto>
{
public override void Configure()
{
// Route HTTP PUT avec un paramètre d'identifiant dans l'URL
Put("/api/products/{@id}", x => new { x.Id });
// Autorise les requêtes anonymes (sans authentification)
AllowAnonymous();
}
public override async Task HandleAsync(UpdateProductDto req, CancellationToken ct)
{
Models.Product? productToEdit = await pyrofetesdbcontext
.Products
.SingleOrDefaultAsync(p => p.Id == req.Id, cancellationToken: ct);
// Recherche du produit à mettre à jour, en incluant les relations Prices et WarehouseProducts
var product = await db.Products
.Include(p => p.Prices)
.Include(p => p.WarehouseProducts)
.SingleOrDefaultAsync(p => p.Id == req.Id, ct);
if (productToEdit == null)
// Si le produit n'existe pas, on retourne une réponse 404
if (product is null)
{
Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}
productToEdit.References = req.Reference;
productToEdit.Name = req.Name;
productToEdit.Duration = req.Duration;
productToEdit.Caliber = req.Caliber;
productToEdit.ApprovalNumber = req.ApprovalNumber;
productToEdit.Weight = req.Weight;
productToEdit.Nec = req.Nec;
productToEdit.SellingPrice = req.SellingPrice;
productToEdit.Image = req.Image;
productToEdit.Link = req.Link;
await pyrofetesdbcontext.SaveChangesAsync(ct);
// Mise à jour des propriétés principales du produit
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.Image = req.Image;
product.Link = req.Link;
product.ClassificationId = req.ClassificationId;
product.ProductCategoryId = req.ProductCategoryId;
GetProductDto responseDto = new()
// Mise à jour des prix fournisseurs associés
db.Prices.RemoveRange(product.Prices);
foreach (var s in req.Suppliers)
{
Id = req.Id,
Reference = req.Reference,
db.Prices.Add(new Price
{
ProductId = product.Id,
SupplierId = s.SupplierId,
SellingPrice = s.SellingPrice
});
}
// Mise à jour des entrepôts associés
db.WarehouseProducts.RemoveRange(product.WarehouseProducts);
foreach (var w in req.Warehouses)
{
db.WarehouseProducts.Add(new WarehouseProduct
{
ProductId = product.Id,
WarehouseId = w.WarehouseId,
Quantity = w.Quantity
});
}
await db.SaveChangesAsync(ct);
// Construction de la réponse renvoyée au client
var response = new GetProductDto
{
Id = product.Id,
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
Link = req.Link,
ClassificationId = req.ClassificationId,
ProductCategoryId = req.ProductCategoryId,
Suppliers = req.Suppliers.Select(s => new ProductSupplierPriceDto
{
SupplierId = s.SupplierId,
SellingPrice = s.SellingPrice
}).ToList(),
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
}).ToList()
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(response, ct);
}
}
}

View File

@@ -4,34 +4,34 @@ using FastEndpoints;
namespace PyroFetes.Endpoints.ProductCategory;
public class CreateProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateProductCategoryDto, GetProductCategoryDto>
public class CreateProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateProductCategoryDto, GetProductCategoryDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateProductCategoryDto et l'élement de réponse GetProductCategoryDto
{
public override void Configure()
public override void Configure() //Configuration de l'endpoint
{
Post("/api/productcategories");
AllowAnonymous();
Post("/api/productcategories"); //Créer une catégorie de produits
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(CreateProductCategoryDto req, CancellationToken ct)
{
Models.ProductCategory productCategory = new ()
Models.ProductCategory productCategory = new () //Création d'un label rentré par l'utilisateur
{
Label = req.Label,
};
pyrofetesdbcontext.ProductCategories.Add(productCategory);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.ProductCategories.Add(productCategory); //Ajout du catégorie de la produit à la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde du catégorie de la produit dans la bdd
Console.WriteLine("Category créé avec succès !");
GetProductCategoryDto responseDto = new ()
GetProductCategoryDto responseDto = new () //renvoie l'id et le label
{
Id = productCategory.Id,
Label = productCategory.Label
};
await Send.OkAsync(responseDto, ct);
await Send.OkAsync(responseDto, ct); //Réponse au client
}
}

Some files were not shown because too many files have changed in this diff Show More