Compare commits
35 Commits
feature/Cr
...
0e74cb40f5
Author | SHA1 | Date | |
---|---|---|---|
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 |
7
PyroFetes/DTO/Brand/Request/CreateBrandDto.cs
Normal file
7
PyroFetes/DTO/Brand/Request/CreateBrandDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace API.DTO.Brand.Request;
|
||||
|
||||
public class CreateBrandDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
}
|
8
PyroFetes/DTO/Brand/Request/UpdateBrandDto.cs
Normal file
8
PyroFetes/DTO/Brand/Request/UpdateBrandDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace API.DTO.Brand.Request;
|
||||
|
||||
public class UpdateBrandDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
}
|
8
PyroFetes/DTO/Brand/Response/GetBrandDto.cs
Normal file
8
PyroFetes/DTO/Brand/Response/GetBrandDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace API.DTO.Brand.Response;
|
||||
|
||||
public class GetBrandDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace API.DTO.Classification.Request;
|
||||
|
||||
public class CreateClassificationDto
|
||||
{
|
||||
public string? Label { get; set; }
|
||||
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
namespace API.DTO.Classification.Request;
|
||||
|
||||
public class UpdateClassificationDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
namespace API.DTO.Classification.Response;
|
||||
|
||||
public class GetClassificationDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
|
||||
}
|
6
PyroFetes/DTO/Color/Request/CreateColorDto.cs
Normal file
6
PyroFetes/DTO/Color/Request/CreateColorDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace API.DTO.Color.Request;
|
||||
|
||||
public class CreateColorDto
|
||||
{
|
||||
public string? Label { get; set; }
|
||||
}
|
7
PyroFetes/DTO/Color/Request/UpdateColorDto.cs
Normal file
7
PyroFetes/DTO/Color/Request/UpdateColorDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace API.DTO.Color.Request;
|
||||
|
||||
public class UpdateColorDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
}
|
7
PyroFetes/DTO/Color/Response/GetColorDto.cs
Normal file
7
PyroFetes/DTO/Color/Response/GetColorDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace API.DTO.Color.Response;
|
||||
|
||||
public class GetColorDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
}
|
6
PyroFetes/DTO/Effect/Request/CreateEffectDto.cs
Normal file
6
PyroFetes/DTO/Effect/Request/CreateEffectDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace API.DTO.Effect.Request;
|
||||
|
||||
public class CreateEffectDto
|
||||
{
|
||||
public string? Label { get; set; }
|
||||
}
|
7
PyroFetes/DTO/Effect/Request/UpdateEffectDto.cs
Normal file
7
PyroFetes/DTO/Effect/Request/UpdateEffectDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace API.DTO.Effect.Request;
|
||||
|
||||
public class UpdateEffectDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
}
|
7
PyroFetes/DTO/Effect/Response/GetEffectDto.cs
Normal file
7
PyroFetes/DTO/Effect/Response/GetEffectDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace API.DTO.Effect.Response;
|
||||
|
||||
public class GetEffectDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
}
|
9
PyroFetes/DTO/Material/Request/CreateMaterialDto.cs
Normal file
9
PyroFetes/DTO/Material/Request/CreateMaterialDto.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace API.DTO.Material.Request;
|
||||
|
||||
public class CreateMaterialDto
|
||||
{
|
||||
public string? Label { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
public int WarehouseId {get; set;}
|
||||
|
||||
}
|
10
PyroFetes/DTO/Material/Request/UpdateMaterialDto.cs
Normal file
10
PyroFetes/DTO/Material/Request/UpdateMaterialDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace API.DTO.Material.Request;
|
||||
|
||||
public class UpdateMaterialDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
public int WarehouseId {get; set;}
|
||||
|
||||
}
|
10
PyroFetes/DTO/Material/Response/GetMaterialDto.cs
Normal file
10
PyroFetes/DTO/Material/Response/GetMaterialDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace API.DTO.Material.Response;
|
||||
|
||||
public class GetMaterialDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
public int WarehouseId {get; set;}
|
||||
|
||||
}
|
10
PyroFetes/DTO/Movement/Request/CreateMovementDto.cs
Normal file
10
PyroFetes/DTO/Movement/Request/CreateMovementDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace API.DTO.Movement.Request;
|
||||
|
||||
public class CreateMovementDto
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public DateTime Start {get; set;}
|
||||
public DateTime Arrival {get; set;}
|
||||
public int Quantity {get; set;}
|
||||
|
||||
}
|
11
PyroFetes/DTO/Movement/Request/UpdateMovementDto.cs
Normal file
11
PyroFetes/DTO/Movement/Request/UpdateMovementDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace API.DTO.Movement.Request;
|
||||
|
||||
public class UpdateMovementDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DateTime Start {get; set;}
|
||||
public DateTime Arrival {get; set;}
|
||||
public int Quantity {get; set;}
|
||||
|
||||
}
|
11
PyroFetes/DTO/Movement/Response/GetMovementDto.cs
Normal file
11
PyroFetes/DTO/Movement/Response/GetMovementDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace API.DTO.Movement.Response;
|
||||
|
||||
public class GetMovementDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DateTime Start {get; set;}
|
||||
public DateTime Arrival {get; set;}
|
||||
public int Quantity {get; set;}
|
||||
|
||||
}
|
26
PyroFetes/DTO/Product/Request/CreateProductDto.cs
Normal file
26
PyroFetes/DTO/Product/Request/CreateProductDto.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using PyroFetes.DTO.Product.Request;
|
||||
|
||||
namespace PyroFetes.DTO.Product.Request
|
||||
{
|
||||
public class CreateProductDto
|
||||
{
|
||||
public int References { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public decimal Duration { get; set; }
|
||||
public decimal Caliber { get; set; }
|
||||
public int ApprovalNumber { get; set; }
|
||||
public decimal Weight { get; set; }
|
||||
public decimal Nec { get; set; }
|
||||
public decimal SellingPrice { get; set; }
|
||||
public string? Image { get; set; }
|
||||
public string? Link { get; set; }
|
||||
public int ClassificationId { get; set;}
|
||||
public int ProductCategoryId { get; set; }
|
||||
|
||||
// Liste des fournisseurs liés au produit
|
||||
public List<ProductSupplierPriceDto>? Suppliers { get; set; }
|
||||
|
||||
// Liste des entrepôts liés au produit
|
||||
public List<CreateProductWarehouseDto>? Warehouses { get; set; }
|
||||
}
|
||||
}
|
27
PyroFetes/DTO/Product/Request/UpdateProductDto.cs
Normal file
27
PyroFetes/DTO/Product/Request/UpdateProductDto.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using PyroFetes.DTO.Product.Request;
|
||||
|
||||
namespace PyroFetes.DTO.Product.Request
|
||||
{
|
||||
public class UpdateProductDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int References { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public decimal Duration { get; set; }
|
||||
public decimal Caliber { get; set; }
|
||||
public int ApprovalNumber { get; set; }
|
||||
public decimal Weight { get; set; }
|
||||
public decimal Nec { get; set; }
|
||||
public decimal SellingPrice { get; set; }
|
||||
public string? Image { get; set; }
|
||||
public string? Link { get; set; }
|
||||
public int ClassificationId { get; set; }
|
||||
public int ProductCategoryId { get; set; }
|
||||
|
||||
// Liste des fournisseurs associés
|
||||
public List<ProductSupplierPriceDto> Suppliers { get; set; } = new();
|
||||
|
||||
// Liste des entrepôts associés
|
||||
public List<UpdateProductWarehouseDto> Warehouses { get; set; } = new();
|
||||
}
|
||||
}
|
29
PyroFetes/DTO/Product/Response/GetProductDto.cs
Normal file
29
PyroFetes/DTO/Product/Response/GetProductDto.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using PyroFetes.DTO.Product.Request;
|
||||
using PyroFetes.DTO.Product.Request;
|
||||
using PyroFetes.DTO.Product.Response;
|
||||
|
||||
namespace PyroFetes.DTO.Product.Response
|
||||
{
|
||||
public class GetProductDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int Reference { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public decimal Duration { get; set; }
|
||||
public decimal Caliber { get; set; }
|
||||
public int ApprovalNumber { get; set; }
|
||||
public decimal Weight { get; set; }
|
||||
public decimal Nec { get; set; }
|
||||
public decimal SellingPrice { get; set; }
|
||||
public string? Image { get; set; }
|
||||
public string? Link { get; set; }
|
||||
public int ClassificationId { get; set; }
|
||||
public int ProductCategoryId { get; set; }
|
||||
|
||||
// Fournisseurs liés
|
||||
public List<ProductSupplierPriceDto> Suppliers { get; set; } = new();
|
||||
|
||||
// Entrepôts liés
|
||||
public List<GetProductWarehouseDto> Warehouses { get; set; } = new();
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
namespace API.DTO.ProductCategory.Request;
|
||||
|
||||
public class CreateProductCategoryDto
|
||||
{
|
||||
public string? Label { get; set; }
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace API.DTO.ProductCategory.Request;
|
||||
|
||||
public class UpdateProductCategoryDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
namespace API.DTO.ProductCategory.Response;
|
||||
|
||||
public class GetProductCategoryDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
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,11 @@
|
||||
namespace PyroFetes.DTO.Product.Response
|
||||
{
|
||||
// DTO pour la lecture des fournisseurs liés à un produit
|
||||
public class GetProductSupplierDto
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int SupplierId { get; set; }
|
||||
public string SupplierName { get; set; } = string.Empty;
|
||||
public decimal SellingPrice { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
namespace PyroFetes.DTO.Product.Request
|
||||
{
|
||||
// DTO utilisé pour créer ou mettre à jour la relation Product <-> Warehouse
|
||||
public class CreateProductWarehouseDto
|
||||
{
|
||||
public int WarehouseId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateProductWarehouseDto
|
||||
{
|
||||
public int WarehouseId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
namespace PyroFetes.DTO.Product.Response
|
||||
{
|
||||
// DTO pour la lecture des entrepôts liés à un produit
|
||||
public class GetProductWarehouseDto
|
||||
{
|
||||
public int WarehouseId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public string WarehouseName { get; set; } = string.Empty;
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
20
PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs
Normal file
20
PyroFetes/DTO/Supplier/Request/CreateSupplierDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace PyroFetes.DTO.Supplier.Request;
|
||||
|
||||
public class CreateSupplierDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public string Adress { get; set; }
|
||||
public int ZipCode { get; set; }
|
||||
public string City { get; set; }
|
||||
|
||||
// Produits que ce fournisseur fournit
|
||||
public List<SupplierProductPriceDto>? Products { get; set; }
|
||||
}
|
||||
|
||||
public class SupplierProductPriceDto
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public decimal SellingPrice { get; set; }
|
||||
}
|
14
PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs
Normal file
14
PyroFetes/DTO/Supplier/Request/UpdateSupplierDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace PyroFetes.DTO.Supplier.Request;
|
||||
|
||||
public class UpdateSupplierDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public string Adress { get; set; }
|
||||
public int ZipCode { get; set; }
|
||||
public string City { get; set; }
|
||||
|
||||
public List<SupplierProductPriceDto>? Products { get; set; }
|
||||
}
|
24
PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs
Normal file
24
PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using PyroFetes.DTO.Supplier.Request;
|
||||
|
||||
namespace PyroFetes.DTO.Supplier.Response;
|
||||
|
||||
public class GetSupplierDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public string Adress { get; set; }
|
||||
public int ZipCode { get; set; }
|
||||
public string City { get; set; }
|
||||
|
||||
// Liste des produits liés avec leur prix fournisseur
|
||||
public List<SupplierProductPriceDto> Products { get; set; }
|
||||
}
|
||||
|
||||
public class GetSupplierProductDto
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public decimal SellingPrice { get; set; }
|
||||
}
|
21
PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs
Normal file
21
PyroFetes/DTO/Warehouse/Request/CreateWarehouseDto.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace API.DTO.Warehouse.Request;
|
||||
|
||||
public class CreateWarehouseDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int MaxWeight { get; set; }
|
||||
public int Current { get; set; }
|
||||
public int MinWeight { get; set; }
|
||||
public string Adress { get; set; }
|
||||
public int ZipCode { get; set; }
|
||||
public string City { get; set; }
|
||||
|
||||
// Liste des produits à stocker dans cet entrepôt
|
||||
public List<CreateWarehouseProductDto>? Products { get; set; }
|
||||
}
|
||||
|
||||
public class CreateWarehouseProductDto
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
21
PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs
Normal file
21
PyroFetes/DTO/Warehouse/Request/UpdateWarehouseDto.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace API.DTO.Warehouse.Request;
|
||||
|
||||
public class UpdateWarehouseDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int MaxWeight { get; set; }
|
||||
public int Current { get; set; }
|
||||
public int MinWeight { get; set; }
|
||||
public string Adress { get; set; }
|
||||
public int ZipCode { get; set; }
|
||||
public string City { get; set; }
|
||||
|
||||
public List<UpdateWarehouseProductDto>? Products { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateWarehouseProductDto
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
22
PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs
Normal file
22
PyroFetes/DTO/Warehouse/Response/GetWarehouseDto.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace API.DTO.Warehouse.Response;
|
||||
|
||||
public class GetWarehouseDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int MaxWeight { get; set; }
|
||||
public int Current { get; set; }
|
||||
public int MinWeight { get; set; }
|
||||
public string Adress { get; set; }
|
||||
public int ZipCode { get; set; }
|
||||
public string City { get; set; }
|
||||
|
||||
public List<WarehouseProductDto>? Products { get; set; }
|
||||
}
|
||||
|
||||
public class WarehouseProductDto
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
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.Request;
|
||||
using API.DTO.Brand.Response;
|
||||
using FastEndpoints;
|
||||
|
||||
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.Request;
|
||||
using API.DTO.Brand.Response;
|
||||
using FastEndpoints;
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
35
PyroFetes/Endpoints/Color/CreateColorEndpoint.cs
Normal file
35
PyroFetes/Endpoints/Color/CreateColorEndpoint.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using API.DTO.Color.Request;
|
||||
using API.DTO.Color.Response;
|
||||
using FastEndpoints;
|
||||
|
||||
namespace PyroFetes.Endpoints.Color;
|
||||
|
||||
public class CreateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateColorDto, GetColorDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/color/create");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateColorDto req, CancellationToken ct)
|
||||
{
|
||||
Models.Color color = new()
|
||||
{
|
||||
Label = req.Label,
|
||||
};
|
||||
|
||||
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("/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("/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("/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("/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("/effect/create");
|
||||
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("/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("/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("/effect/{@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("/effect/{@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("/material/create");
|
||||
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("/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("/material");
|
||||
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("/material/{@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("/material/{@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);
|
||||
}
|
||||
}
|
51
PyroFetes/Endpoints/Supplier/DeleteSupplierEndpoint.cs
Normal file
51
PyroFetes/Endpoints/Supplier/DeleteSupplierEndpoint.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Endpoints.Supplier;
|
||||
|
||||
public class DeleteSupplierRequest
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class DeleteSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteSupplierRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/api/suppliers/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct)
|
||||
{
|
||||
var supplierToDelete = await pyrofetesdbcontext
|
||||
.Suppliers
|
||||
.SingleOrDefaultAsync(s => s.Id == req.Id, ct);
|
||||
|
||||
if (supplierToDelete is null)
|
||||
{
|
||||
Console.WriteLine($"Aucun fournisseur avec l'ID {req.Id} trouvé.");
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
// Supprimer les liaisons Price avant le fournisseur
|
||||
var relatedPrices = await pyrofetesdbcontext.Prices
|
||||
.Where(p => p.SupplierId == req.Id)
|
||||
.ToListAsync(ct);
|
||||
|
||||
if (relatedPrices.Any())
|
||||
{
|
||||
pyrofetesdbcontext.Prices.RemoveRange(relatedPrices);
|
||||
}
|
||||
|
||||
// Supprimer le fournisseur
|
||||
pyrofetesdbcontext.Suppliers.Remove(supplierToDelete);
|
||||
|
||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||
Console.WriteLine($"Fournisseur {req.Id} et ses prix liés supprimés avec succès.");
|
||||
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
44
PyroFetes/Endpoints/Supplier/GetAllSupplierEndpoint.cs
Normal file
44
PyroFetes/Endpoints/Supplier/GetAllSupplierEndpoint.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using PyroFetes.DTO.Supplier.Response;
|
||||
using PyroFetes.DTO.Supplier.Request;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Endpoints.Supplier;
|
||||
|
||||
public class GetAllSuppliersEndpoint(PyroFetesDbContext pyrofetesdbcontext)
|
||||
: EndpointWithoutRequest<List<GetSupplierDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/suppliers");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
var suppliers = await pyrofetesdbcontext.Suppliers
|
||||
.Include(s => s.Prices)
|
||||
.ToListAsync(ct);
|
||||
|
||||
var responseDto = suppliers.Select(s => new GetSupplierDto
|
||||
{
|
||||
Id = s.Id,
|
||||
Name = s.Name!,
|
||||
Email = s.Email!,
|
||||
PhoneNumber = s.Phone!,
|
||||
Adress = s.Address!,
|
||||
ZipCode = s.ZipCode,
|
||||
City = s.City!,
|
||||
|
||||
// 🔹 Liste des produits liés via Price
|
||||
Products = s.Prices.Select(pr => new SupplierProductPriceDto
|
||||
{
|
||||
ProductId = pr.ProductId,
|
||||
SellingPrice = pr.SellingPrice
|
||||
}).ToList()
|
||||
}).ToList();
|
||||
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
}
|
||||
}
|
55
PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs
Normal file
55
PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using PyroFetes.DTO.Supplier.Request;
|
||||
using PyroFetes.DTO.Supplier.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PyroFetes.Endpoints.Supplier;
|
||||
|
||||
public class GetSupplierRequest
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class GetSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext)
|
||||
: Endpoint<GetSupplierRequest, GetSupplierDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/suppliers/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetSupplierRequest req, CancellationToken ct)
|
||||
{
|
||||
var supplier = await pyrofetesdbcontext.Suppliers
|
||||
.Include(s => s.Prices)
|
||||
.SingleOrDefaultAsync(s => s.Id == req.Id, ct);
|
||||
|
||||
if (supplier == null)
|
||||
{
|
||||
Console.WriteLine($"Aucun fournisseur avec l'ID {req.Id} trouvé.");
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
var responseDto = new GetSupplierDto
|
||||
{
|
||||
Id = supplier.Id,
|
||||
Name = supplier.Name!,
|
||||
Email = supplier.Email!,
|
||||
PhoneNumber = supplier.Phone!,
|
||||
Adress = supplier.Address!,
|
||||
ZipCode = supplier.ZipCode,
|
||||
City = supplier.City!,
|
||||
|
||||
// Produits liés
|
||||
Products = supplier.Prices.Select(p => new SupplierProductPriceDto
|
||||
{
|
||||
ProductId = p.ProductId,
|
||||
SellingPrice = p.SellingPrice
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
}
|
||||
}
|
70
PyroFetes/Endpoints/Supplier/UpdateSupplierEndpoint.cs
Normal file
70
PyroFetes/Endpoints/Supplier/UpdateSupplierEndpoint.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using PyroFetes.DTO.Supplier.Request;
|
||||
using PyroFetes.DTO.Supplier.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Endpoints.Supplier;
|
||||
|
||||
public class UpdateSupplierEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateSupplierDto, GetSupplierDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Put("/api/suppliers/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateSupplierDto req, CancellationToken ct)
|
||||
{
|
||||
var supplierToEdit = await pyrofetesdbcontext
|
||||
.Suppliers
|
||||
.Include(s => s.Prices)
|
||||
.SingleOrDefaultAsync(s => s.Id == req.Id, ct);
|
||||
|
||||
if (supplierToEdit is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
supplierToEdit.Name = req.Name;
|
||||
supplierToEdit.Email = req.Email;
|
||||
supplierToEdit.Phone = req.PhoneNumber;
|
||||
supplierToEdit.Address = req.Adress;
|
||||
supplierToEdit.ZipCode = req.ZipCode;
|
||||
supplierToEdit.City = req.City;
|
||||
|
||||
if (req.Products is not null)
|
||||
{
|
||||
// Supprimer les anciennes liaisons
|
||||
var existingPrices = pyrofetesdbcontext.Prices
|
||||
.Where(p => p.SupplierId == supplierToEdit.Id);
|
||||
pyrofetesdbcontext.Prices.RemoveRange(existingPrices);
|
||||
|
||||
// Ajouter les nouvelles liaisons
|
||||
foreach (var p in req.Products)
|
||||
{
|
||||
pyrofetesdbcontext.Prices.Add(new Price
|
||||
{
|
||||
SupplierId = supplierToEdit.Id,
|
||||
ProductId = p.ProductId,
|
||||
SellingPrice = p.SellingPrice
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||
|
||||
var response = new GetSupplierDto
|
||||
{
|
||||
Id = supplierToEdit.Id,
|
||||
Name = supplierToEdit.Name,
|
||||
Email = supplierToEdit.Email,
|
||||
PhoneNumber = supplierToEdit.Phone,
|
||||
Adress = supplierToEdit.Address,
|
||||
ZipCode = supplierToEdit.ZipCode,
|
||||
City = supplierToEdit.City
|
||||
};
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
}
|
||||
}
|
63
PyroFetes/Endpoints/Warehouse/CreateWarehouseEndpoint.cs
Normal file
63
PyroFetes/Endpoints/Warehouse/CreateWarehouseEndpoint.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using API.DTO.Warehouse.Request;
|
||||
using API.DTO.Warehouse.Response;
|
||||
using FastEndpoints;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Endpoints.Warehouse;
|
||||
|
||||
public class CreateWarehouseEndpoint(PyroFetesDbContext db)
|
||||
: Endpoint<CreateWarehouseDto, GetWarehouseDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/warehouse");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateWarehouseDto req, CancellationToken ct)
|
||||
{
|
||||
var warehouse = new Models.Warehouse
|
||||
{
|
||||
Name = req.Name,
|
||||
MaxWeight = req.MaxWeight,
|
||||
Current = req.Current,
|
||||
MinWeight = req.MinWeight,
|
||||
Address = req.Adress,
|
||||
ZipCode = req.ZipCode,
|
||||
City = req.City
|
||||
};
|
||||
|
||||
db.Warehouses.Add(warehouse);
|
||||
await db.SaveChangesAsync(ct);
|
||||
|
||||
// 🔹 Ajout des produits liés à cet entrepôt
|
||||
if (req.Products is not null && req.Products.Any())
|
||||
{
|
||||
foreach (var p in req.Products)
|
||||
{
|
||||
var warehouseProduct = new WarehouseProduct
|
||||
{
|
||||
WarehouseId = warehouse.Id,
|
||||
ProductId = p.ProductId,
|
||||
Quantity = p.Quantity
|
||||
};
|
||||
db.WarehouseProducts.Add(warehouseProduct);
|
||||
}
|
||||
await db.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
var response = new GetWarehouseDto
|
||||
{
|
||||
Id = warehouse.Id,
|
||||
Name = warehouse.Name,
|
||||
MaxWeight = warehouse.MaxWeight,
|
||||
Current = warehouse.Current,
|
||||
MinWeight = warehouse.MinWeight,
|
||||
Adress = warehouse.Address,
|
||||
ZipCode = warehouse.ZipCode,
|
||||
City = warehouse.City
|
||||
};
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
}
|
||||
}
|
52
PyroFetes/Endpoints/Warehouse/DeleteWarehouseEndpoint.cs
Normal file
52
PyroFetes/Endpoints/Warehouse/DeleteWarehouseEndpoint.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Endpoints.Warehouse;
|
||||
|
||||
public class DeleteWarehouseRequest
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class DeleteWarehouseEndpoint(PyroFetesDbContext db) : Endpoint<DeleteWarehouseRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
// L’annotation correcte du paramètre est {id}, pas {@id}
|
||||
Delete("/api/warehouse/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(DeleteWarehouseRequest req, CancellationToken ct)
|
||||
{
|
||||
// On charge aussi les WarehouseProducts liés pour les supprimer proprement
|
||||
var warehouseToDelete = await db.Warehouses
|
||||
.Include(w => w.WarehouseProducts)
|
||||
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
if (warehouseToDelete == null)
|
||||
{
|
||||
Console.WriteLine($"Aucun entrepôt avec l'ID {req.Id} trouvé.");
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔹 Suppression des relations WarehouseProduct avant l'entrepôt
|
||||
var relatedWarehouseProducts = await db.WarehouseProducts
|
||||
.Where(wp => wp.WarehouseId == req.Id)
|
||||
.ToListAsync(ct);
|
||||
|
||||
if (relatedWarehouseProducts.Any())
|
||||
{
|
||||
db.WarehouseProducts.RemoveRange(relatedWarehouseProducts);
|
||||
}
|
||||
|
||||
// 🔹 Suppression de l’entrepôt
|
||||
db.Warehouses.Remove(warehouseToDelete);
|
||||
await db.SaveChangesAsync(ct);
|
||||
|
||||
Console.WriteLine($"Entrepôt {warehouseToDelete.Name} (ID {req.Id}) supprimé avec succès.");
|
||||
await Send.NoContentAsync(ct);
|
||||
}
|
||||
}
|
46
PyroFetes/Endpoints/Warehouse/GetAllWarehouseEndpoint.cs
Normal file
46
PyroFetes/Endpoints/Warehouse/GetAllWarehouseEndpoint.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using API.DTO.Warehouse.Response;
|
||||
using API.DTO.Warehouse.Request;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Endpoints.Warehouse;
|
||||
|
||||
public class GetAllWarehouseEndpoint(PyroFetesDbContext db)
|
||||
: EndpointWithoutRequest<List<GetWarehouseDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/warehouses");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
// 🔹 On inclut les relations avec WarehouseProducts et Product
|
||||
var warehouses = await db.Warehouses
|
||||
.Include(w => w.WarehouseProducts)
|
||||
.ThenInclude(wp => wp.Product)
|
||||
.ToListAsync(ct);
|
||||
|
||||
var response = warehouses.Select(w => new GetWarehouseDto
|
||||
{
|
||||
Id = w.Id,
|
||||
Name = w.Name,
|
||||
MaxWeight = w.MaxWeight,
|
||||
Current = w.Current,
|
||||
MinWeight = w.MinWeight,
|
||||
Adress = w.Address,
|
||||
ZipCode = w.ZipCode,
|
||||
City = w.City,
|
||||
Products = w.WarehouseProducts.Select(wp => new WarehouseProductDto
|
||||
{
|
||||
ProductId = wp.ProductId,
|
||||
ProductName = wp.Product?.Name,
|
||||
Quantity = wp.Quantity
|
||||
}).ToList()
|
||||
}).ToList();
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
}
|
||||
}
|
58
PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs
Normal file
58
PyroFetes/Endpoints/Warehouse/GetWarehouseEndpoint.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using API.DTO.Warehouse.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Endpoints.Warehouse;
|
||||
|
||||
public class GetWarehouseRequest
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class GetWarehouseEndpoint(PyroFetesDbContext db)
|
||||
: Endpoint<GetWarehouseRequest, GetWarehouseDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
// Pas de "@id" ici, juste {id}
|
||||
Get("/api/warehouses/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetWarehouseRequest req, CancellationToken ct)
|
||||
{
|
||||
// 🔹 Inclut les produits associés à cet entrepôt
|
||||
var warehouse = await db.Warehouses
|
||||
.Include(w => w.WarehouseProducts)
|
||||
.ThenInclude(wp => wp.Product)
|
||||
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
if (warehouse == null)
|
||||
{
|
||||
Console.WriteLine($" Aucun entrepôt avec l'ID {req.Id} trouvé.");
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
var response = new GetWarehouseDto
|
||||
{
|
||||
Id = warehouse.Id,
|
||||
Name = warehouse.Name!,
|
||||
MaxWeight = warehouse.MaxWeight,
|
||||
Current = warehouse.Current,
|
||||
MinWeight = warehouse.MinWeight,
|
||||
Adress = warehouse.Address!,
|
||||
ZipCode = warehouse.ZipCode,
|
||||
City = warehouse.City!,
|
||||
Products = warehouse.WarehouseProducts.Select(wp => new WarehouseProductDto
|
||||
{
|
||||
ProductId = wp.ProductId,
|
||||
ProductName = wp.Product?.Name,
|
||||
Quantity = wp.Quantity
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
await Send.OkAsync(response, ct);
|
||||
}
|
||||
}
|
86
PyroFetes/Endpoints/Warehouse/UpdateWarehouseEndpoint.cs
Normal file
86
PyroFetes/Endpoints/Warehouse/UpdateWarehouseEndpoint.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using API.DTO.Warehouse.Request;
|
||||
using API.DTO.Warehouse.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Endpoints.Warehouse;
|
||||
|
||||
public class UpdateWarehouseEndpoint(PyroFetesDbContext db)
|
||||
: Endpoint<UpdateWarehouseDto, GetWarehouseDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
// Utilise {id} plutôt que {@id}
|
||||
Put("/api/warehouses/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateWarehouseDto req, CancellationToken ct)
|
||||
{
|
||||
// 🔹 On inclut les produits existants pour pouvoir les modifier
|
||||
var warehouseToEdit = await db.Warehouses
|
||||
.Include(w => w.WarehouseProducts)
|
||||
.SingleOrDefaultAsync(w => w.Id == req.Id, cancellationToken: ct);
|
||||
|
||||
if (warehouseToEdit == null)
|
||||
{
|
||||
Console.WriteLine($"Aucun entrepôt avec l'ID {req.Id} trouvé.");
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔹 Mise à jour des champs de base
|
||||
warehouseToEdit.Name = req.Name;
|
||||
warehouseToEdit.MaxWeight = req.MaxWeight;
|
||||
warehouseToEdit.Current = req.Current;
|
||||
warehouseToEdit.MinWeight = req.MinWeight;
|
||||
warehouseToEdit.Address = req.Adress;
|
||||
warehouseToEdit.ZipCode = req.ZipCode;
|
||||
warehouseToEdit.City = req.City;
|
||||
|
||||
// 🔹 Gestion des produits associés
|
||||
if (req.Products is not null)
|
||||
{
|
||||
// On supprime les anciens liens pour recréer proprement
|
||||
var existingLinks = warehouseToEdit.WarehouseProducts.ToList();
|
||||
if (existingLinks.Any())
|
||||
db.WarehouseProducts.RemoveRange(existingLinks);
|
||||
|
||||
foreach (var p in req.Products)
|
||||
{
|
||||
var newLink = new WarehouseProduct
|
||||
{
|
||||
WarehouseId = warehouseToEdit.Id,
|
||||
ProductId = p.ProductId,
|
||||
Quantity = p.Quantity
|
||||
};
|
||||
db.WarehouseProducts.Add(newLink);
|
||||
}
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync(ct);
|
||||
|
||||
// 🔹 On renvoie la version mise à jour
|
||||
var response = new GetWarehouseDto
|
||||
{
|
||||
Id = warehouseToEdit.Id,
|
||||
Name = warehouseToEdit.Name,
|
||||
MaxWeight = warehouseToEdit.MaxWeight,
|
||||
Current = warehouseToEdit.Current,
|
||||
MinWeight = warehouseToEdit.MinWeight,
|
||||
Adress = warehouseToEdit.Address,
|
||||
ZipCode = warehouseToEdit.ZipCode,
|
||||
City = warehouseToEdit.City,
|
||||
Products = warehouseToEdit.WarehouseProducts.Select(wp => new WarehouseProductDto
|
||||
{
|
||||
ProductId = wp.ProductId,
|
||||
ProductName = wp.Product?.Name,
|
||||
Quantity = wp.Quantity
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
Console.WriteLine($"Entrepôt {warehouseToEdit.Name} mis à jour avec succès.");
|
||||
await Send.OkAsync(response, ct);
|
||||
}
|
||||
}
|
@@ -1,18 +1,19 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
using API;
|
||||
using FastEndpoints;
|
||||
using FastEndpoints.Swagger;
|
||||
using PyroFetes;
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var app = builder.Build();
|
||||
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
|
||||
builder.Services.AddFastEndpoints().SwaggerDocument();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
// On ajoute ici la configuration de la base de données
|
||||
builder.Services.AddDbContext<PyroFetesDbContext>();
|
||||
|
||||
// On construit l'application en lui donnant vie
|
||||
WebApplication app = builder.Build();
|
||||
app.UseFastEndpoints().UseSwaggerGen();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FastEndpoints" Version="7.0.1" />
|
||||
<PackageReference Include="FastEndpoints.Swagger" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.20">
|
||||
|
50
README.md
Normal file
50
README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Gestionnaire de Stocks et Commandes
|
||||
|
||||
Cette application web permet de **suivre les stocks**, **automatiser les commandes fournisseurs** et **gérer le cycle complet d’approvisionnement**.
|
||||
Elle est conçue pour simplifier le travail des entreprises en offrant une vue en temps réel sur les produits, leurs fournisseurs et l’état des livraisons.
|
||||
|
||||
---
|
||||
|
||||
## ✨ Fonctionnalités principales
|
||||
|
||||
### 1️⃣ Suivi et réapprovisionnement des stocks
|
||||
- Définissez un **niveau minimal de stock** pour chaque produit.
|
||||
- Surveillez les **niveaux en temps réel** grâce à une interface claire.
|
||||
- Lorsqu’un produit atteint ou descend sous son seuil minimal, le système **génère automatiquement un bon de commande** pour le réapprovisionner.
|
||||
|
||||
### 2️⃣ Gestion des fournisseurs
|
||||
- Enregistrez les informations complètes des fournisseurs : nom, adresse, coordonnées, produits fournis, délais de livraison.
|
||||
- **Associez un ou plusieurs fournisseurs** à chaque produit.
|
||||
- Lorsqu’un bon de commande est créé, le système **propose automatiquement les fournisseurs appropriés**.
|
||||
|
||||
### 3️⃣ Devis et bons de commande
|
||||
- Créez des **devis personnalisés** : sélection des produits, quantités, prix, ajout d’un logo, message ou conditions de vente.
|
||||
- **Imprimez ou exportez** vos devis au format PDF.
|
||||
- Générez des **bons de commande** en quelques clics, avec personnalisation (logo, conditions d’achat) et exportation en PDF.
|
||||
|
||||
### 4️⃣ Suivi des livraisons
|
||||
- **Transformez un bon de commande en bon de livraison** dès l’expédition des produits par le fournisseur.
|
||||
- Enregistrez toutes les informations importantes : date d’expédition, transporteur, numéro de suivi, date prévue et date effective de livraison.
|
||||
- Recevez des **alertes en cas de retard**.
|
||||
- Gérez la **réception des produits** et vérifiez leur conformité.
|
||||
|
||||
---
|
||||
|
||||
## 🗂️ Livrables prévus
|
||||
- **Modèle de données** : diagramme de classes commun à tous les groupes.
|
||||
- **Interface utilisateur** : maquettes ou prototypes interactifs.
|
||||
- **Code source commenté** pour une meilleure compréhension.
|
||||
- **Documentation technique** : description des fonctionnalités, architecture de l’application et API.
|
||||
|
||||
---
|
||||
|
||||
## 👥 Équipe
|
||||
- **Mathys**
|
||||
- **Enzo**
|
||||
- **Cristiano**
|
||||
- **Arsène**
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Objectif
|
||||
Fournir un outil complet pour automatiser la gestion des stocks et des commandes, réduisant les erreurs humaines, améliorant le suivi des livraisons et facilitant la communication avec les fournisseurs.
|
Reference in New Issue
Block a user