Compare commits
41 Commits
master
...
90d685d42c
| Author | SHA1 | Date | |
|---|---|---|---|
| 90d685d42c | |||
| 2bcca6f856 | |||
| 6d564c89ff | |||
| bad259e9f5 | |||
| 32dee6eb18 | |||
| b3347fe163 | |||
| 0e74cb40f5 | |||
| 91b4aca2fa | |||
| 1734ec0219 | |||
| 7a8daa6ab8 | |||
| 8f4171a045 | |||
| 8a8a47c99c | |||
| bb5dd63da2 | |||
| c5805d979b | |||
| 44da6ed371 | |||
| 08bf910437 | |||
| d1fa3aca68 | |||
| f155d03559 | |||
| f3ed82f4a4 | |||
| 22275b63f2 | |||
| 018f7c5c25 | |||
| 81ab26f765 | |||
| 75ab503dfc | |||
| 52f0e84323 | |||
| 9b9ec133aa | |||
| 4aa6db31b0 | |||
| 149cd9eb33 | |||
| d7bc054cb5 | |||
| abe508bd7c | |||
| 94ea571a42 | |||
| 93d259638a | |||
| e6030cacf2 | |||
| ccaaf25dbc | |||
| abc1c42b53 | |||
| 7e3eaa3b51 | |||
| 658d346dd0 | |||
| 997d7c64fb | |||
| 81854417d8 | |||
| 423f8f9645 | |||
| bd8495b79a | |||
| c729af3d32 |
9
PyroFetes/DTO/Brand/Request/CreateBrandDto.cs
Normal file
9
PyroFetes/DTO/Brand/Request/CreateBrandDto.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace PyroFetes.DTO.Brand.Request
|
||||||
|
{
|
||||||
|
// DTO pour créer une nouvelle marque
|
||||||
|
public class CreateBrandDto
|
||||||
|
{
|
||||||
|
// Nom de la marque
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
12
PyroFetes/DTO/Brand/Request/UpdateBrandDto.cs
Normal file
12
PyroFetes/DTO/Brand/Request/UpdateBrandDto.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace PyroFetes.DTO.Brand.Request
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
12
PyroFetes/DTO/Brand/Response/GetBrandDto.cs
Normal file
12
PyroFetes/DTO/Brand/Response/GetBrandDto.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace API.DTO.Brand.Response
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// Définition de l'espace de noms pour les DTO liés à la création de classifications
|
||||||
|
namespace API.DTO.Classification.Request
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Définition de l'espace de noms pour les DTO liés à la mise à jour de classifications
|
||||||
|
namespace API.DTO.Classification.Request
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
11
PyroFetes/DTO/Color/Request/CreateColorDto.cs
Normal file
11
PyroFetes/DTO/Color/Request/CreateColorDto.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
PyroFetes/DTO/Color/Request/UpdateColorDto.cs
Normal file
14
PyroFetes/DTO/Color/Request/UpdateColorDto.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
PyroFetes/DTO/Color/Response/GetColorDto.cs
Normal file
14
PyroFetes/DTO/Color/Response/GetColorDto.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
11
PyroFetes/DTO/Effect/Request/CreateEffectDto.cs
Normal file
11
PyroFetes/DTO/Effect/Request/CreateEffectDto.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
PyroFetes/DTO/Effect/Request/UpdateEffectDto.cs
Normal file
14
PyroFetes/DTO/Effect/Request/UpdateEffectDto.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
PyroFetes/DTO/Effect/Response/GetEffectDto.cs
Normal file
14
PyroFetes/DTO/Effect/Response/GetEffectDto.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
PyroFetes/DTO/Material/Request/CreateMaterialDto.cs
Normal file
17
PyroFetes/DTO/Material/Request/CreateMaterialDto.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
20
PyroFetes/DTO/Material/Request/UpdateMaterialDto.cs
Normal file
20
PyroFetes/DTO/Material/Request/UpdateMaterialDto.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
20
PyroFetes/DTO/Material/Response/GetMaterialDto.cs
Normal file
20
PyroFetes/DTO/Material/Response/GetMaterialDto.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
19
PyroFetes/DTO/Movement/Request/CreateMovementDto.cs
Normal file
19
PyroFetes/DTO/Movement/Request/CreateMovementDto.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
22
PyroFetes/DTO/Movement/Request/UpdateMovementDto.cs
Normal file
22
PyroFetes/DTO/Movement/Request/UpdateMovementDto.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
22
PyroFetes/DTO/Movement/Response/GetMovementDto.cs
Normal file
22
PyroFetes/DTO/Movement/Response/GetMovementDto.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// 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
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.Price.Request;
|
|
||||||
|
|
||||||
public class CreatePriceDto
|
|
||||||
{
|
|
||||||
public decimal SellingPrice { get; set; }
|
|
||||||
|
|
||||||
public int SupplierId { get; set; }
|
|
||||||
public string? SupplierName { get; set; }
|
|
||||||
public string? SupplierEmail { get; set; }
|
|
||||||
public string? SupplierPhone { get; set; }
|
|
||||||
public string? SupplierAddress { get; set; }
|
|
||||||
public int SupplierZipCode { get; set; }
|
|
||||||
public string? SupplierCity { get; set; }
|
|
||||||
public int SupplierDeliveryDelay { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.Price.Request;
|
|
||||||
|
|
||||||
public class PatchPriceSellingPriceDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public decimal SellingPrice { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.Price.Request;
|
|
||||||
|
|
||||||
public class UpdatePriceDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public decimal SellingPrice { get; set; }
|
|
||||||
|
|
||||||
public int SupplierId { get; set; }
|
|
||||||
public string? SupplierName { get; set; }
|
|
||||||
public string? SupplierEmail { get; set; }
|
|
||||||
public string? SupplierPhone { get; set; }
|
|
||||||
public string? SupplierAddress { get; set; }
|
|
||||||
public int SupplierZipCode { get; set; }
|
|
||||||
public string? SupplierCity { get; set; }
|
|
||||||
public int SupplierDeliveryDelay { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.Price.Response;
|
|
||||||
|
|
||||||
public class GetPriceDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public decimal SellingPrice { get; set; }
|
|
||||||
|
|
||||||
public int SupplierId { get; set; }
|
|
||||||
public string? SupplierName { get; set; }
|
|
||||||
public string? SupplierEmail { get; set; }
|
|
||||||
public string? SupplierPhone { get; set; }
|
|
||||||
public string? SupplierAddress { get; set; }
|
|
||||||
public int SupplierZipCode { get; set; }
|
|
||||||
public string? SupplierCity { get; set; }
|
|
||||||
public int SupplierDeliveryDelay { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,50 @@
|
|||||||
namespace PyroFetes.DTO.Product.Request;
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.DTO.Product.Request
|
||||||
|
{
|
||||||
|
// DTO utilisé lors de la création d’un produit
|
||||||
public class CreateProductDto
|
public class CreateProductDto
|
||||||
{
|
{
|
||||||
|
// Référence interne du produit
|
||||||
public int References { get; set; }
|
public int References { get; set; }
|
||||||
|
|
||||||
|
// Nom du produit
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
// Durée de l’effet du produit
|
||||||
public decimal Duration { get; set; }
|
public decimal Duration { get; set; }
|
||||||
|
|
||||||
|
// Calibre du produit
|
||||||
public decimal Caliber { get; set; }
|
public decimal Caliber { get; set; }
|
||||||
|
|
||||||
|
// Numéro d’homologation
|
||||||
public int ApprovalNumber { get; set; }
|
public int ApprovalNumber { get; set; }
|
||||||
|
|
||||||
|
// Poids du produit
|
||||||
public decimal Weight { get; set; }
|
public decimal Weight { get; set; }
|
||||||
|
|
||||||
|
// Matière active (NEC)
|
||||||
public decimal Nec { get; set; }
|
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; }
|
public string? Image { get; set; }
|
||||||
|
|
||||||
|
// Lien vers une ressource externe (vidéo, fiche, etc.)
|
||||||
public string? Link { get; set; }
|
public string? Link { get; set; }
|
||||||
public int MinimalQuantity { 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; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.Product.Request;
|
|
||||||
|
|
||||||
public class PatchProductMinimalStockDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int MinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,53 @@
|
|||||||
namespace PyroFetes.DTO.Product.Request;
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.DTO.Product.Request
|
||||||
|
{
|
||||||
|
// DTO utilisé pour la mise à jour d’un produit existant
|
||||||
public class UpdateProductDto
|
public class UpdateProductDto
|
||||||
{
|
{
|
||||||
|
// Identifiant unique du produit à modifier
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
// Référence interne du produit
|
||||||
public int References { get; set; }
|
public int References { get; set; }
|
||||||
|
|
||||||
|
// Nom du produit
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
// Durée de l’effet du produit
|
||||||
public decimal Duration { get; set; }
|
public decimal Duration { get; set; }
|
||||||
|
|
||||||
|
// Calibre du produit
|
||||||
public decimal Caliber { get; set; }
|
public decimal Caliber { get; set; }
|
||||||
|
|
||||||
|
// Numéro d’homologation
|
||||||
public int ApprovalNumber { get; set; }
|
public int ApprovalNumber { get; set; }
|
||||||
|
|
||||||
|
// Poids du produit
|
||||||
public decimal Weight { get; set; }
|
public decimal Weight { get; set; }
|
||||||
|
|
||||||
|
// Matière active (NEC)
|
||||||
public decimal Nec { get; set; }
|
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; }
|
public string? Image { get; set; }
|
||||||
|
|
||||||
|
// Lien vers une ressource externe (fiche, vidéo, etc.)
|
||||||
public string? Link { get; set; }
|
public string? Link { get; set; }
|
||||||
public int MinimalQuantity { 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,54 @@
|
|||||||
namespace PyroFetes.DTO.Product.Response;
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.DTO.Product.Response
|
||||||
|
{
|
||||||
|
// DTO utilisé pour renvoyer les informations complètes d’un produit
|
||||||
public class GetProductDto
|
public class GetProductDto
|
||||||
{
|
{
|
||||||
|
// Identifiant unique du produit
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int References { get; set; }
|
|
||||||
|
// Référence interne du produit
|
||||||
|
public int Reference { get; set; }
|
||||||
|
|
||||||
|
// Nom du produit
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
// Durée de l’effet du produit
|
||||||
public decimal Duration { get; set; }
|
public decimal Duration { get; set; }
|
||||||
|
|
||||||
|
// Calibre du produit
|
||||||
public decimal Caliber { get; set; }
|
public decimal Caliber { get; set; }
|
||||||
|
|
||||||
|
// Numéro d’homologation
|
||||||
public int ApprovalNumber { get; set; }
|
public int ApprovalNumber { get; set; }
|
||||||
|
|
||||||
|
// Poids du produit
|
||||||
public decimal Weight { get; set; }
|
public decimal Weight { get; set; }
|
||||||
|
|
||||||
|
// Matière active (NEC)
|
||||||
public decimal Nec { get; set; }
|
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; }
|
public string? Image { get; set; }
|
||||||
|
|
||||||
|
// Lien externe vers plus d’informations (fiche, vidéo, etc.)
|
||||||
public string? Link { get; set; }
|
public string? Link { get; set; }
|
||||||
public int MinimalQuantity { 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace API.DTO.ProductCategory.Request
|
||||||
|
{
|
||||||
|
// DTO pour créer une catégorie de produit
|
||||||
|
public class CreateProductCategoryDto
|
||||||
|
{
|
||||||
|
// Nom de la catégorie
|
||||||
|
public string? Label { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace API.DTO.ProductCategory.Request
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace API.DTO.ProductCategory.Response
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
namespace PyroFetes.DTO.Product.Response
|
||||||
|
{
|
||||||
|
// DTO utilisé pour renvoyer les informations d’un 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
namespace PyroFetes.DTO.Product.Request
|
||||||
|
{
|
||||||
|
// DTO utilisé lors de la création d’une 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 d’une 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
namespace PyroFetes.DTO.Product.Response
|
||||||
|
{
|
||||||
|
// DTO utilisé pour renvoyer les informations d’un 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 l’affichage)
|
||||||
|
public string WarehouseName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
// Quantité du produit stockée dans cet entrepôt
|
||||||
|
public int Quantity { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.PurchaseProduct.Request;
|
|
||||||
|
|
||||||
public class CreatePurchaseProductDto
|
|
||||||
{
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public int PurchaseOrderId { get; set; }
|
|
||||||
public string? PurchaseOrderPurchaseConditions { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.PurchaseProduct.Request;
|
|
||||||
|
|
||||||
public class PatchPurchaseProductQuantityDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.PurchaseProduct.Request;
|
|
||||||
|
|
||||||
public class UpdatePurchaseProductDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public int PurchaseOrderId { get; set; }
|
|
||||||
public string? PurchaseOrderPurchaseConditions { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.PurchaseProduct.Response;
|
|
||||||
|
|
||||||
public class GetPurchaseProductDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public decimal ProductSellingPrice { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public int PurchaseOrderId { get; set; }
|
|
||||||
public string? PurchaseOrderPurchaseConditions { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.QuotationProduct.Request;
|
|
||||||
|
|
||||||
public class CreateQuotationProductDto
|
|
||||||
{
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int QuotationId { get; set; }
|
|
||||||
public string? QuotationMessage { get; set; }
|
|
||||||
public string? QuotationConditionsSale { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.QuotationProduct.Request;
|
|
||||||
|
|
||||||
public class PatchQuotationProductQuantityDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.QuotationProduct.Request;
|
|
||||||
|
|
||||||
public class UpdateQuotationProductDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int QuotationId { get; set; }
|
|
||||||
public string? QuotationMessage { get; set; }
|
|
||||||
public string? QuotationConditionsSale { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.QuotationProduct.Response;
|
|
||||||
|
|
||||||
public class GetQuotationProductDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int QuotationId { get; set; }
|
|
||||||
public string? QuotationMessage { get; set; }
|
|
||||||
public string? QuotationConditionsSale { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.SettingDTO.Request;
|
|
||||||
|
|
||||||
public class CreateSettingDto
|
|
||||||
{
|
|
||||||
public string? ElectronicSignature { get; set; }
|
|
||||||
public string? Logo { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.SettingDTO.Request;
|
|
||||||
|
|
||||||
public class PatchSettingElectronicSignatureDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string? ElectronicSignature { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.SettingDTO.Request;
|
|
||||||
|
|
||||||
public class PatchSettingLogoDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string? Logo { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.SettingDTO.Response;
|
|
||||||
|
|
||||||
public class GetSettingDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string? ElectronicSignature { get; set; }
|
|
||||||
public string? Logo { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,37 @@
|
|||||||
namespace PyroFetes.DTO.Supplier.Request;
|
namespace PyroFetes.DTO.Supplier.Request
|
||||||
|
{
|
||||||
|
// DTO pour créer un nouveau fournisseur
|
||||||
public class CreateSupplierDto
|
public class CreateSupplierDto
|
||||||
{
|
{
|
||||||
public string? Name { get; set; }
|
// Nom du fournisseur
|
||||||
public string? Email { get; set; }
|
public string Name { get; set; }
|
||||||
public string? Phone { get; set; }
|
|
||||||
public string? Address { 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; }
|
public int ZipCode { get; set; }
|
||||||
public string? City { get; set; }
|
|
||||||
public int DeliveryDelay { 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; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.Supplier.Request;
|
|
||||||
|
|
||||||
public class PatchSupplierDeliveryDelayDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int DeliveryDelay { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,30 @@
|
|||||||
namespace PyroFetes.DTO.Supplier.Request;
|
namespace PyroFetes.DTO.Supplier.Request
|
||||||
|
{
|
||||||
|
// DTO pour mettre à jour un fournisseur existant
|
||||||
public class UpdateSupplierDto
|
public class UpdateSupplierDto
|
||||||
{
|
{
|
||||||
|
// Identifiant du fournisseur à mettre à jour
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string? Name { get; set; }
|
|
||||||
public string? Email { get; set; }
|
// Nom du fournisseur
|
||||||
public string? Phone { get; set; }
|
public string Name { get; set; }
|
||||||
public string? Address { 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; }
|
public int ZipCode { get; set; }
|
||||||
public string? City { get; set; }
|
|
||||||
public int DeliveryDelay { 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; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,45 @@
|
|||||||
namespace PyroFetes.DTO.Supplier.Response;
|
using PyroFetes.DTO.Supplier.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.DTO.Supplier.Response
|
||||||
|
{
|
||||||
|
// DTO pour récupérer les informations d'un fournisseur
|
||||||
public class GetSupplierDto
|
public class GetSupplierDto
|
||||||
{
|
{
|
||||||
|
// Identifiant du fournisseur
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string? Name { get; set; }
|
|
||||||
public string? Email { get; set; }
|
// Nom du fournisseur
|
||||||
public string? Phone { get; set; }
|
public string Name { get; set; }
|
||||||
public string? Address { 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; }
|
public int ZipCode { get; set; }
|
||||||
public string? City { get; set; }
|
|
||||||
public int DeliveryDelay { 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; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.User.Request;
|
|
||||||
|
|
||||||
public class CreateUserDto
|
|
||||||
{
|
|
||||||
public string? Name { get; set; }
|
|
||||||
public string? Password { get; set; }
|
|
||||||
public string? Salt { get; set; }
|
|
||||||
public string? Fonction { get; set; }
|
|
||||||
public string? Email { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.User.Request;
|
|
||||||
|
|
||||||
public class UpdateUserDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string? Name { get; set; }
|
|
||||||
public string? Password { get; set; }
|
|
||||||
public string? Fonction { get; set; }
|
|
||||||
public string? Email { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.User.Response;
|
|
||||||
|
|
||||||
public class GetUserDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string? Name { get; set; }
|
|
||||||
public string? Password { get; set; }
|
|
||||||
public string? Salt { get; set; }
|
|
||||||
public string? Fonction { get; set; }
|
|
||||||
public string? Email { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.WareHouseProduct.Request;
|
|
||||||
|
|
||||||
public class CreateWareHouseProductDto
|
|
||||||
{
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int WareHouseId { get; set; }
|
|
||||||
public string? WareHouseName {get; set;}
|
|
||||||
public int WareHouseMaxWeight {get; set;}
|
|
||||||
public int WareHouseCurrent {get; set;}
|
|
||||||
public int WareHouseMinWeight {get; set;}
|
|
||||||
public string? WareHouseAddress { get; set; }
|
|
||||||
public int WareHouseZipCode { get; set; }
|
|
||||||
public string? WareHouseCity { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.WareHouseProduct.Request;
|
|
||||||
|
|
||||||
public class PatchWareHouseProductQuantityDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.WareHouseProduct.Request;
|
|
||||||
|
|
||||||
public class UpdateWareHouseProductDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int WareHouseId { get; set; }
|
|
||||||
public string? WareHouseName {get; set;}
|
|
||||||
public int WareHouseMaxWeight {get; set;}
|
|
||||||
public int WareHouseCurrent {get; set;}
|
|
||||||
public int WareHouseMinWeight {get; set;}
|
|
||||||
public string? WareHouseAddress { get; set; }
|
|
||||||
public int WareHouseZipCode { get; set; }
|
|
||||||
public string? WareHouseCity { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
namespace PyroFetes.DTO.WareHouseProduct.Response;
|
|
||||||
|
|
||||||
public class GetWareHouseProductDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
|
|
||||||
public int WareHouseId { get; set; }
|
|
||||||
public string? WareHouseName {get; set;}
|
|
||||||
public int WareHouseMaxWeight {get; set;}
|
|
||||||
public int WareHouseCurrent {get; set;}
|
|
||||||
public int WareHouseMinWeight {get; set;}
|
|
||||||
public string? WareHouseAddress { get; set; }
|
|
||||||
public int WareHouseZipCode { get; set; }
|
|
||||||
public string? WareHouseCity { get; set; }
|
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
|
||||||
public int ProductReferences { get; set; }
|
|
||||||
public string? ProductName { get; set; }
|
|
||||||
public decimal ProductDuration {get; set;}
|
|
||||||
public decimal ProductCaliber { get; set; }
|
|
||||||
public int ProductApprovalNumber { get; set; }
|
|
||||||
public decimal ProductWeight { get; set; }
|
|
||||||
public decimal ProductNec { get; set; }
|
|
||||||
public string? ProductImage { get; set; }
|
|
||||||
public string? ProductLink { get; set; }
|
|
||||||
public int ProductMinimalQuantity { get; set; }
|
|
||||||
}
|
|
||||||
40
PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs
Normal file
40
PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
namespace API.DTO.Warehouse.Request
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
43
PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs
Normal file
43
PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
namespace API.DTO.Warehouse.Request
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
46
PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs
Normal file
46
PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
namespace API.DTO.Warehouse.Response
|
||||||
|
{
|
||||||
|
// 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
35
PyroFetes/Endpoints/Brand/CreateBrandEndpoint.cs
Normal file
35
PyroFetes/Endpoints/Brand/CreateBrandEndpoint.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
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 override void Configure()
|
||||||
|
{
|
||||||
|
Post("/api/brands");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateBrandDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Brand brand = new ()
|
||||||
|
{
|
||||||
|
Name = req.Name
|
||||||
|
};
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Brands.Add(brand);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
Console.WriteLine("Marque créé avec succès !");
|
||||||
|
|
||||||
|
GetBrandDto responseDto = new ()
|
||||||
|
{
|
||||||
|
Name = req.Name
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
PyroFetes/Endpoints/Brand/DeleteBrandEndpoint.cs
Normal file
38
PyroFetes/Endpoints/Brand/DeleteBrandEndpoint.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Brand;
|
||||||
|
|
||||||
|
public class DeleteBrandRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteBrandRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/api/brands/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteBrandRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Brand? brandToDelete = await pyrofetesdbcontext
|
||||||
|
.Brands
|
||||||
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (brandToDelete == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Aucune marque avec l'ID {req.Id} trouvé.");
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Brands.Remove(brandToDelete);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.NoContentAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
PyroFetes/Endpoints/Brand/GetAllBrandsEndpoint.cs
Normal file
28
PyroFetes/Endpoints/Brand/GetAllBrandsEndpoint.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using API.DTO.Brand.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Brand;
|
||||||
|
|
||||||
|
public class GetAllBrandsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetBrandDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/brands");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
List<GetBrandDto> responseDto = await pyrofetesdbcontext.Brands
|
||||||
|
.Select(a => new GetBrandDto
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Name = a.Name,
|
||||||
|
}
|
||||||
|
).ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
PyroFetes/Endpoints/Brand/GetBrandEndpoint.cs
Normal file
42
PyroFetes/Endpoints/Brand/GetBrandEndpoint.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using API.DTO.Brand.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Brand;
|
||||||
|
|
||||||
|
public class GetBrandRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<GetBrandRequest, GetBrandDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/brands/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetBrandRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Brand? brand = await pyrofetesdbcontext
|
||||||
|
.Brands
|
||||||
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (brand == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Aucune marque avec l'ID {req.Id} trouvé.");
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetBrandDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Name = brand.Name
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
PyroFetes/Endpoints/Brand/UpdateBrandEndpoint.cs
Normal file
34
PyroFetes/Endpoints/Brand/UpdateBrandEndpoint.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using API.DTO.Brand.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using PyroFetes.DTO.Brand.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Brand;
|
||||||
|
|
||||||
|
public class UpdateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateBrandDto, GetBrandDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/api/brands");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateBrandDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Brand brand = new()
|
||||||
|
{
|
||||||
|
Name = req.Name
|
||||||
|
};
|
||||||
|
pyrofetesdbcontext.Add(brand);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
GetBrandDto response = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Name = req.Name
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(response, ct);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using API.DTO.Classification.Request;
|
||||||
|
using API.DTO.Classification.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Classification;
|
||||||
|
|
||||||
|
public class CreateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateClassificationDto, GetClassificationDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/api/classifications");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateClassificationDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Classification classification = new ()
|
||||||
|
{
|
||||||
|
Label = req.Label
|
||||||
|
};
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Classifications.Add(classification);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
Console.WriteLine("Classification créée avec succès !");
|
||||||
|
|
||||||
|
GetClassificationDto responseDto = new ()
|
||||||
|
{
|
||||||
|
Label = req.Label
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Classification;
|
||||||
|
|
||||||
|
public class DeleteClassificationRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteClassificationEndpoint(PyroFetesDbContext libraryDbContext) : Endpoint<DeleteClassificationRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/api/classifications/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteClassificationRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Classification? classificationToDelete = await libraryDbContext
|
||||||
|
.Classifications
|
||||||
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (classificationToDelete == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Aucune classification avec l'ID {req.Id} trouvé.");
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
libraryDbContext.Classifications.Remove(classificationToDelete);
|
||||||
|
await libraryDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.NoContentAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using API.DTO.Classification.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Classification;
|
||||||
|
|
||||||
|
public class GetAllClassificationsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetClassificationDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/classifications");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
List<GetClassificationDto> responseDto = await pyrofetesdbcontext.Classifications
|
||||||
|
.Select(a => new GetClassificationDto
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Label = a.Label,
|
||||||
|
}
|
||||||
|
).ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using API.DTO.Classification.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Classification;
|
||||||
|
|
||||||
|
public class GetClassificationRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<GetClassificationRequest, GetClassificationDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/classifications/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetClassificationRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Classification? classification = await pyrofetesdbcontext
|
||||||
|
.Classifications
|
||||||
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (classification == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Aucune classification avec l'ID {req.Id} trouvé.");
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClassificationDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Label = classification.Label
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using API.DTO.Classification.Request;
|
||||||
|
using API.DTO.Classification.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Classification;
|
||||||
|
|
||||||
|
public class UpdateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateClassificationDto, GetClassificationDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/api/classifications");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateClassificationDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Classification classification = new()
|
||||||
|
{
|
||||||
|
Label = req.Label
|
||||||
|
};
|
||||||
|
pyrofetesdbcontext.Add(classification);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
GetClassificationDto response = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Label = req.Label
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(response, ct);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
36
PyroFetes/Endpoints/Color/CreateColorEndpoint.cs
Normal file
36
PyroFetes/Endpoints/Color/CreateColorEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
37
PyroFetes/Endpoints/Color/DeleteColorEndpoint.cs
Normal file
37
PyroFetes/Endpoints/Color/DeleteColorEndpoint.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Color;
|
||||||
|
|
||||||
|
public class DeleteColorRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteColorRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("Api/colors/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Color? colorToDelete = await pyrofetesdbcontext
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Colors.Remove(colorToDelete);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.NoContentAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
PyroFetes/Endpoints/Color/GetAllColorsEndpoint.cs
Normal file
26
PyroFetes/Endpoints/Color/GetAllColorsEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
Get("Api/colors");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
List<GetColorDto> responseDto = await pyrofetesdbcontext.Colors
|
||||||
|
.Select(a => new GetColorDto
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Label = a.Label,
|
||||||
|
}
|
||||||
|
).ToListAsync(ct);
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
41
PyroFetes/Endpoints/Color/GetColorEndpoint.cs
Normal file
41
PyroFetes/Endpoints/Color/GetColorEndpoint.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
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});
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Color? color = await pyrofetesdbcontext
|
||||||
|
.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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
41
PyroFetes/Endpoints/Color/UpdateColorEndpoint.cs
Normal file
41
PyroFetes/Endpoints/Color/UpdateColorEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
Put("Api/colors/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Color? colorToEdit = await pyrofetesdbcontext
|
||||||
|
.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 pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
GetColorDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Label = req.Label,
|
||||||
|
};
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
34
PyroFetes/Endpoints/Effect/CreateEffectEndpoint.cs
Normal file
34
PyroFetes/Endpoints/Effect/CreateEffectEndpoint.cs
Normal 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>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("Api/effects");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateEffectDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Effect effect = new()
|
||||||
|
{
|
||||||
|
Label = req.Label,
|
||||||
|
};
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Effects.Add(effect);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
Console.WriteLine("Effect added");
|
||||||
|
|
||||||
|
GetEffectDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = effect.Id,
|
||||||
|
Label = req.Label,
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
PyroFetes/Endpoints/Effect/DeleteEffectEndpoint.cs
Normal file
36
PyroFetes/Endpoints/Effect/DeleteEffectEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
Delete("Api/effects/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Effect? effectToDelete = await pyrofetesdbcontext
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Effects.Remove(effectToDelete);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.NoContentAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
PyroFetes/Endpoints/Effect/GetAllEffectsEndpoint.cs
Normal file
27
PyroFetes/Endpoints/Effect/GetAllEffectsEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
Get("Api/effects");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
List<GetEffectDto> responseDto = await pyrofetesdbcontext.Effects
|
||||||
|
.Select(a => new GetEffectDto
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Label = a.Label,
|
||||||
|
}
|
||||||
|
).ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
41
PyroFetes/Endpoints/Effect/GetEffectEndpoint.cs
Normal file
41
PyroFetes/Endpoints/Effect/GetEffectEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
Get("Api/effects/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Effect? effect = await pyrofetesdbcontext
|
||||||
|
.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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
41
PyroFetes/Endpoints/Effect/UpdateEffectEndpoint.cs
Normal file
41
PyroFetes/Endpoints/Effect/UpdateEffectEndpoint.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
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()
|
||||||
|
{
|
||||||
|
Put("Api/effects/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Effect? effectToEdit = await pyrofetesdbcontext
|
||||||
|
.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 pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
GetEffectDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Label = req.Label,
|
||||||
|
};
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
37
PyroFetes/Endpoints/Material/CreateMaterialEndpoint.cs
Normal file
37
PyroFetes/Endpoints/Material/CreateMaterialEndpoint.cs
Normal 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>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("Api/materials");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateMaterialDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Material quantity = new()
|
||||||
|
{
|
||||||
|
Name = req.Label,
|
||||||
|
Quantity = req.Quantity,
|
||||||
|
WarehouseId = req.WarehouseId,
|
||||||
|
};
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Materials.Add(quantity);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
Console.WriteLine("Material added");
|
||||||
|
|
||||||
|
GetMaterialDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = quantity.Id,
|
||||||
|
WarehouseId = quantity.WarehouseId,
|
||||||
|
Label = req.Label,
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
PyroFetes/Endpoints/Material/DeleteMaterialEndpoint.cs
Normal file
35
PyroFetes/Endpoints/Material/DeleteMaterialEndpoint.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Material;
|
||||||
|
public class DeleteMaterialRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
public class DeleteMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteMaterialRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("Api/materials/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Material? materialToDelete = await pyrofetesdbcontext
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Materials.Remove(materialToDelete);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.NoContentAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint.cs
Normal file
28
PyroFetes/Endpoints/Material/GetAllMaterialsEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
Get("Api/materials");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
List<GetMaterialDto> responseDto = await pyrofetesdbcontext.Materials
|
||||||
|
.Select(a => new GetMaterialDto
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Label = a.Name,
|
||||||
|
Quantity = a.Quantity,
|
||||||
|
WarehouseId = a.WarehouseId,
|
||||||
|
}
|
||||||
|
).ToListAsync(ct);
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
PyroFetes/Endpoints/Material/GetMaterialEndpoint.cs
Normal file
42
PyroFetes/Endpoints/Material/GetMaterialEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
Get("Api/materials/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Material? material = await pyrofetesdbcontext
|
||||||
|
.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,
|
||||||
|
Label = material.Name,
|
||||||
|
WarehouseId = material.WarehouseId,
|
||||||
|
};
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
42
PyroFetes/Endpoints/Material/UpdateMaterialEndpoint.cs
Normal file
42
PyroFetes/Endpoints/Material/UpdateMaterialEndpoint.cs
Normal 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()
|
||||||
|
{
|
||||||
|
Put("Api/materials/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.Material? materialToEdit = await pyrofetesdbcontext
|
||||||
|
.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.Label;
|
||||||
|
materialToEdit.WarehouseId = req.WarehouseId;
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
GetMaterialDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Label = req.Label,
|
||||||
|
WarehouseId = req.WarehouseId,
|
||||||
|
};
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
41
PyroFetes/Endpoints/Movement/CreateMovementEndpoint.cs
Normal file
41
PyroFetes/Endpoints/Movement/CreateMovementEndpoint.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using API.DTO.Movement.Request;
|
||||||
|
using API.DTO.Movement.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Movement;
|
||||||
|
|
||||||
|
public class CreateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateMovementDto, GetMovementDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/api/movements");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateMovementDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Movement movement = new ()
|
||||||
|
{
|
||||||
|
Date = req.Date,
|
||||||
|
Start = req.Start,
|
||||||
|
Arrival = req.Arrival,
|
||||||
|
Quantity = req.Quantity
|
||||||
|
};
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Movements.Add(movement);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
Console.WriteLine("Movement créée avec succès !");
|
||||||
|
|
||||||
|
GetMovementDto responseDto = new ()
|
||||||
|
{
|
||||||
|
Date = req.Date,
|
||||||
|
Start = req.Start,
|
||||||
|
Arrival = req.Arrival,
|
||||||
|
Quantity = req.Quantity
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
PyroFetes/Endpoints/Movement/DeleteMovementEndpoint.cs
Normal file
38
PyroFetes/Endpoints/Movement/DeleteMovementEndpoint.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Movement;
|
||||||
|
|
||||||
|
public class DeleteMovementRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteMovementRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/api/Movements/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteMovementRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Movement? movementToDelete = await pyrofetesdbcontext
|
||||||
|
.Movements
|
||||||
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (movementToDelete == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Aucune mouvement avec l'ID {req.Id} trouvé.");
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Movements.Remove(movementToDelete);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.NoContentAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
31
PyroFetes/Endpoints/Movement/GetAllMovementsEndpoint.cs
Normal file
31
PyroFetes/Endpoints/Movement/GetAllMovementsEndpoint.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using API.DTO.Movement.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Movement;
|
||||||
|
|
||||||
|
public class GetAllMovementsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMovementDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/movements");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
List<GetMovementDto> responseDto = await pyrofetesdbcontext.Movements
|
||||||
|
.Select(a => new GetMovementDto
|
||||||
|
{
|
||||||
|
Id = a.Id,
|
||||||
|
Date = a.Date,
|
||||||
|
Start = a.Start,
|
||||||
|
Arrival = a.Arrival,
|
||||||
|
Quantity = a.Quantity
|
||||||
|
}
|
||||||
|
).ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
45
PyroFetes/Endpoints/Movement/GetMovementEndpoint.cs
Normal file
45
PyroFetes/Endpoints/Movement/GetMovementEndpoint.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using API.DTO.Movement.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Movement;
|
||||||
|
|
||||||
|
public class GetMovementRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<GetMovementRequest, GetMovementDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/movements/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetMovementRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Movement? movement = await pyrofetesdbcontext
|
||||||
|
.Movements
|
||||||
|
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (movement == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Aucun mouvement avec l'ID {req.Id} trouvé.");
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetMovementDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Date = movement.Date,
|
||||||
|
Start = movement.Start,
|
||||||
|
Arrival = movement.Arrival,
|
||||||
|
Quantity = movement.Quantity
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
PyroFetes/Endpoints/Movement/UpdateMovementEndpoint.cs
Normal file
40
PyroFetes/Endpoints/Movement/UpdateMovementEndpoint.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using API.DTO.Movement.Request;
|
||||||
|
using API.DTO.Movement.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Movement;
|
||||||
|
|
||||||
|
public class UpdateMovementEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateMovementDto, GetMovementDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/api/movements");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateMovementDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
|
||||||
|
Models.Movement movement = new()
|
||||||
|
{
|
||||||
|
Date = req.Date,
|
||||||
|
Start = req.Start,
|
||||||
|
Arrival = req.Arrival,
|
||||||
|
Quantity = req.Quantity
|
||||||
|
};
|
||||||
|
pyrofetesdbcontext.Add(movement);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
GetMovementDto response = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Date = req.Date,
|
||||||
|
Start = req.Start,
|
||||||
|
Arrival = req.Arrival,
|
||||||
|
Quantity = req.Quantity
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(response, ct);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
108
PyroFetes/Endpoints/Product/CreateProductEndpoint.cs
Normal file
108
PyroFetes/Endpoints/Product/CreateProductEndpoint.cs
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
|
public class CreateProductEndpoint(PyroFetesDbContext db)
|
||||||
|
: Endpoint<CreateProductDto, GetProductDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/api/products");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateProductDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var product = new Models.Product
|
||||||
|
{
|
||||||
|
References = req.References,
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
db.Products.Add(product);
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construction de la réponse
|
||||||
|
var response = new GetProductDto
|
||||||
|
{
|
||||||
|
Id = product.Id,
|
||||||
|
Reference = req.References,
|
||||||
|
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,
|
||||||
|
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(response, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
59
PyroFetes/Endpoints/Product/DeleteProductEndpoint.cs
Normal file
59
PyroFetes/Endpoints/Product/DeleteProductEndpoint.cs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
|
public class DeleteProductRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteProductEndpoint(PyroFetesDbContext db) : Endpoint<DeleteProductRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/api/products/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteProductRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
// Récupérer le produit
|
||||||
|
var productToDelete = await db.Products
|
||||||
|
.SingleOrDefaultAsync(p => p.Id == req.Id, ct);
|
||||||
|
|
||||||
|
if (productToDelete is null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé.");
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer les liaisons Price
|
||||||
|
var relatedPrices = await db.Prices
|
||||||
|
.Where(p => p.ProductId == req.Id)
|
||||||
|
.ToListAsync(ct);
|
||||||
|
if (relatedPrices.Any())
|
||||||
|
{
|
||||||
|
db.Prices.RemoveRange(relatedPrices);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
63
PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs
Normal file
63
PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
|
public class GetAllProductsEndpoint(PyroFetesDbContext db)
|
||||||
|
: EndpointWithoutRequest<List<GetProductDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/products");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken 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,
|
||||||
|
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,
|
||||||
|
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 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
75
PyroFetes/Endpoints/Product/GetProductEndpoint.cs
Normal file
75
PyroFetes/Endpoints/Product/GetProductEndpoint.cs
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
|
public class GetProductRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetProductEndpoint(PyroFetesDbContext db)
|
||||||
|
: Endpoint<GetProductRequest, GetProductDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/products/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetProductRequest req, 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)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Aucun produit avec l'ID {req.Id} trouvé.");
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var responseDto = new GetProductDto
|
||||||
|
{
|
||||||
|
Id = product.Id,
|
||||||
|
Reference = product.References,
|
||||||
|
Name = product.Name,
|
||||||
|
Duration = product.Duration,
|
||||||
|
Caliber = product.Caliber,
|
||||||
|
ApprovalNumber = product.ApprovalNumber,
|
||||||
|
Weight = product.Weight,
|
||||||
|
Nec = product.Nec,
|
||||||
|
SellingPrice = product.SellingPrice,
|
||||||
|
Image = product.Image,
|
||||||
|
Link = product.Link,
|
||||||
|
ClassificationId = product.ClassificationId,
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
119
PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs
Normal file
119
PyroFetes/Endpoints/Product/UpdateProductEndpoint.cs
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Product.Request;
|
||||||
|
using PyroFetes.DTO.Product.Response;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Product;
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// Si le produit n'existe pas, on retourne une réponse 404
|
||||||
|
if (product is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mise à jour des propriétés principales du produit
|
||||||
|
product.References = req.References;
|
||||||
|
product.Name = req.Name;
|
||||||
|
product.Duration = req.Duration;
|
||||||
|
product.Caliber = req.Caliber;
|
||||||
|
product.ApprovalNumber = req.ApprovalNumber;
|
||||||
|
product.Weight = req.Weight;
|
||||||
|
product.Nec = req.Nec;
|
||||||
|
product.SellingPrice = req.SellingPrice;
|
||||||
|
product.Image = req.Image;
|
||||||
|
product.Link = req.Link;
|
||||||
|
product.ClassificationId = req.ClassificationId;
|
||||||
|
product.ProductCategoryId = req.ProductCategoryId;
|
||||||
|
|
||||||
|
// Mise à jour des prix fournisseurs associés
|
||||||
|
// On supprime les anciens enregistrements pour les remplacer
|
||||||
|
db.Prices.RemoveRange(product.Prices);
|
||||||
|
foreach (var s in req.Suppliers)
|
||||||
|
{
|
||||||
|
db.Prices.Add(new Price
|
||||||
|
{
|
||||||
|
ProductId = product.Id,
|
||||||
|
SupplierId = s.SupplierId,
|
||||||
|
SellingPrice = s.SellingPrice
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mise à jour des entrepôts associés
|
||||||
|
// On supprime les anciens liens avant d'ajouter les nouveaux
|
||||||
|
db.WarehouseProducts.RemoveRange(product.WarehouseProducts);
|
||||||
|
foreach (var w in req.Warehouses)
|
||||||
|
{
|
||||||
|
db.WarehouseProducts.Add(new WarehouseProduct
|
||||||
|
{
|
||||||
|
ProductId = product.Id,
|
||||||
|
WarehouseId = w.WarehouseId,
|
||||||
|
Quantity = w.Quantity
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sauvegarde des modifications dans la base de données
|
||||||
|
await db.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
// Construction de la réponse renvoyée au client
|
||||||
|
// On reconstruit les listes Suppliers et Warehouses au bon format de DTO
|
||||||
|
var response = new GetProductDto
|
||||||
|
{
|
||||||
|
Id = product.Id,
|
||||||
|
Reference = req.References,
|
||||||
|
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,
|
||||||
|
ClassificationId = req.ClassificationId,
|
||||||
|
ProductCategoryId = req.ProductCategoryId,
|
||||||
|
|
||||||
|
// Mapping des fournisseurs pour la réponse
|
||||||
|
Suppliers = req.Suppliers.Select(s => new ProductSupplierPriceDto
|
||||||
|
{
|
||||||
|
SupplierId = s.SupplierId,
|
||||||
|
SellingPrice = s.SellingPrice
|
||||||
|
}).ToList(),
|
||||||
|
|
||||||
|
// Mapping des entrepôts pour la réponse
|
||||||
|
Warehouses = req.Warehouses.Select(w => new GetProductWarehouseDto
|
||||||
|
{
|
||||||
|
WarehouseId = w.WarehouseId,
|
||||||
|
Quantity = w.Quantity,
|
||||||
|
WarehouseName = db.Warehouses.FirstOrDefault(x => x.Id == w.WarehouseId)?.Name ?? string.Empty
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
// Envoi de la réponse HTTP 200 avec les données du produit mis à jour
|
||||||
|
await Send.OkAsync(response, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using API.DTO.ProductCategory.Request;
|
||||||
|
using API.DTO.ProductCategory.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.ProductCategory;
|
||||||
|
|
||||||
|
public class CreateProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateProductCategoryDto, GetProductCategoryDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/api/productcategories");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateProductCategoryDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.ProductCategory productCategory = new ()
|
||||||
|
{
|
||||||
|
Label = req.Label,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
pyrofetesdbcontext.ProductCategories.Add(productCategory);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
Console.WriteLine("Category créé avec succès !");
|
||||||
|
|
||||||
|
GetProductCategoryDto responseDto = new ()
|
||||||
|
{
|
||||||
|
Id = productCategory.Id,
|
||||||
|
Label = productCategory.Label
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.ProductCategory;
|
||||||
|
|
||||||
|
public class DeleteProductCategoryRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteProductCategoryRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/api/productcategories/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteProductCategoryRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.ProductCategory? productCategoryToDelete = await pyrofetesdbcontext
|
||||||
|
.ProductCategories
|
||||||
|
.SingleOrDefaultAsync(pc => pc.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (productCategoryToDelete == null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pyrofetesdbcontext.ProductCategories.Remove(productCategoryToDelete);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.NoContentAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using API.DTO.ProductCategory.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.ProductCategory;
|
||||||
|
|
||||||
|
public class GetAllProductCategoriesEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetProductCategoryDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/productcategories");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
List<GetProductCategoryDto> responseDto = await pyrofetesdbcontext.ProductCategories
|
||||||
|
.Select(pc => new GetProductCategoryDto()
|
||||||
|
{
|
||||||
|
Id = pc.Id,
|
||||||
|
Label = pc.Label
|
||||||
|
}
|
||||||
|
).ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using API.DTO.ProductCategory.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.ProductCategory;
|
||||||
|
|
||||||
|
public class GetProductCategoryRequest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class GetProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<GetProductCategoryRequest, GetProductCategoryDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/api/productcategory/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetProductCategoryRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.ProductCategory? productCategory = await pyrofetesdbcontext
|
||||||
|
.ProductCategories
|
||||||
|
.SingleOrDefaultAsync(pc => pc.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (productCategory == null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetProductCategoryDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = productCategory.Id,
|
||||||
|
Label = productCategory.Label
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using API.DTO.ProductCategory.Request;
|
||||||
|
using API.DTO.ProductCategory.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.ProductCategory;
|
||||||
|
|
||||||
|
public class UpdateProductCategoryEndpoint(PyroFetesDbContext pyrofetesdbcontext) :Endpoint<UpdateProductCategoryDto, GetProductCategoryDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/api/productcategory/{@id}", x => new { x.Id });
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateProductCategoryDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
Models.ProductCategory? productCategoryToEdit = await pyrofetesdbcontext
|
||||||
|
.ProductCategories
|
||||||
|
.SingleOrDefaultAsync(pc => pc.Id == req.Id, cancellationToken: ct);
|
||||||
|
|
||||||
|
if (productCategoryToEdit == null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
productCategoryToEdit.Label = req.Label;
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
GetProductCategoryDto responseDto = new()
|
||||||
|
{
|
||||||
|
Id = req.Id,
|
||||||
|
Label = req.Label,
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(responseDto, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
62
PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs
Normal file
62
PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using PyroFetes.DTO.Supplier.Request;
|
||||||
|
using PyroFetes.DTO.Supplier.Response;
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Supplier;
|
||||||
|
|
||||||
|
public class CreateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext)
|
||||||
|
: Endpoint<CreateSupplierDto, GetSupplierDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/api/suppliers");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var supplier = new Models.Supplier
|
||||||
|
{
|
||||||
|
Name = req.Name,
|
||||||
|
Email = req.Email,
|
||||||
|
Phone = req.PhoneNumber,
|
||||||
|
Address = req.Adress,
|
||||||
|
ZipCode = req.ZipCode,
|
||||||
|
City = req.City
|
||||||
|
};
|
||||||
|
|
||||||
|
pyrofetesdbcontext.Suppliers.Add(supplier);
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
// Ajout des liaisons Price si produits renseignés
|
||||||
|
if (req.Products is not null && req.Products.Any())
|
||||||
|
{
|
||||||
|
foreach (var p in req.Products)
|
||||||
|
{
|
||||||
|
var price = new Price
|
||||||
|
{
|
||||||
|
SupplierId = supplier.Id,
|
||||||
|
ProductId = p.ProductId,
|
||||||
|
SellingPrice = p.SellingPrice
|
||||||
|
};
|
||||||
|
pyrofetesdbcontext.Prices.Add(price);
|
||||||
|
}
|
||||||
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = new GetSupplierDto
|
||||||
|
{
|
||||||
|
Id = supplier.Id,
|
||||||
|
Name = supplier.Name,
|
||||||
|
Email = supplier.Email,
|
||||||
|
PhoneNumber = supplier.Phone,
|
||||||
|
Adress = supplier.Address,
|
||||||
|
ZipCode = supplier.ZipCode,
|
||||||
|
City = supplier.City
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(response, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user