99 Commits

Author SHA1 Message Date
Cristiano
7f3ffde3ff Merge branch 'develop' 2025-11-27 14:56:14 +01:00
Cristiano
50a5f371dd Fixed Database 2025-11-27 14:35:35 +01:00
86c5d6ae7b new migration 2025-11-27 13:41:55 +01:00
1c0432a2c4 updated length of password in User.cs 2025-11-27 13:40:02 +01:00
6be43958fa updated length of password to 60 for bcrypt length 2025-11-27 13:28:05 +01:00
3e8f36457e fixed errors in database 2025-11-26 20:37:49 +01:00
5d68ee6992 fix length on approval number 2025-11-26 19:43:54 +01:00
Cristiano
d26284d552 Merge branch 'feature/repositories-refactor' into develop 2025-11-20 16:45:55 +01:00
Cristiano
d537051bea Fix Type errors 2025-11-20 16:45:44 +01:00
Cristiano
3ad506f869 Retired /api in all the endpoints 2025-11-20 16:33:56 +01:00
Cristiano
9aac7c39f2 Merge branch 'feature/repositories-refactor' into develop
# Conflicts:
#	PyroFetes/Endpoints/Price/CreatePriceEndpoint.cs
#	PyroFetes/Endpoints/Product/GetAllProductsEndpoint.cs
#	PyroFetes/Endpoints/Product/GetProductEndpoint.cs
#	PyroFetes/Endpoints/PurchaseOrder/GetAllPurchaseOrderEndpoint.cs
#	PyroFetes/Endpoints/PurchaseOrder/GetPurchaseOrderEndpoint.cs
#	PyroFetes/Endpoints/Quotation/GetAllQuotationEndpoint.cs
#	PyroFetes/Endpoints/Quotation/GetQuotationEndpoint.cs
#	PyroFetes/Endpoints/SettingEndpoints/CreateSettingEndpoint.cs
#	PyroFetes/Endpoints/SettingEndpoints/PatchSettingElectronicSignatureEndpoint.cs
#	PyroFetes/Endpoints/SettingEndpoints/PatchSettingLogoEndpoint.cs
#	PyroFetes/Endpoints/Supplier/CreateSupplierEndpoint.cs
#	PyroFetes/Endpoints/Supplier/GetAllSuppliersEndpoint.cs
#	PyroFetes/Endpoints/Supplier/GetSupplierEndpoint.cs
#	PyroFetes/Endpoints/Supplier/PatchSupplierDeleveryDelayEndpoint.cs
#	PyroFetes/Endpoints/User/GetAllUsersEndpoint.cs
#	PyroFetes/Endpoints/User/GetUserEndpoint.cs
2025-11-20 16:16:15 +01:00
Cristiano
b76b668097 Addapted to use cors and optimized connection with the frontend 2025-11-20 16:12:16 +01:00
Cristiano
669938d677 Refactored WarehouseProduct 2025-11-20 16:09:04 +01:00
Cristiano
165c9b9322 Refactored User 2025-11-20 15:38:53 +01:00
Cristiano
0b72549143 Refactored Program.cs 2025-11-20 15:20:13 +01:00
Cristiano
d64890dec9 Refactored Supplier 2025-11-20 15:11:14 +01:00
Cristiano
8325aa0768 Refactored Setting 2025-11-20 15:05:44 +01:00
Cristiano
ee9b4675dd Refactored Quotation 2025-11-20 14:34:09 +01:00
Cristiano
f6383265ba Refactored QuotationProduct 2025-11-20 14:20:25 +01:00
Cristiano
7bf0b5bfd1 Advanced refactoring 2025-11-20 14:04:13 +01:00
Cristiano
bd653c149c Finished refactoring prices endpoints 2025-11-19 18:05:28 +01:00
0511bb5075 added AllowAnonymous(); 2025-11-17 21:25:07 +01:00
27e8fea7f3 added AllowAnonymous(); 2025-11-17 21:20:04 +01:00
6dba61f742 suppr all 'var' and Models.xxx. And added 's' at the end of all directories endpoints 2025-11-17 20:49:12 +01:00
Cristiano
20bbccf883 Added last endpoints for delivery Note 2025-11-14 18:11:54 +01:00
Cristiano
d7cf245d35 Committed migration 2025-11-13 17:28:41 +01:00
Cristiano
2385b7b687 Made an update on database and added CreatingDeliveryNotee 2025-11-13 17:28:08 +01:00
Cristiano
ae834d1e3c Adapted Price Endpoints 2025-11-13 16:31:00 +01:00
Cristiano
c6d4ef2c58 Adapted Deliverer endpoints with repository spec and automapper 2025-11-13 15:26:22 +01:00
Cristiano
60a7c059b4 Merge remote-tracking branch 'origin/develop' into develop 2025-11-13 14:44:46 +01:00
Cristiano
9684dbcbc7 Merged AutoMapper branch 2025-11-13 14:44:28 +01:00
bbd8d3d36a Actualiser PyroFetes/DTO/Price/Request/CreatePriceDto.cs 2025-11-09 18:48:23 +01:00
7d92f80de3 Actualiser PyroFetes/Endpoints/Price/CreatePriceEndpoint.cs 2025-11-09 18:46:24 +01:00
304c06ed19 changed setting for SettingEndpoints 2025-11-07 17:45:35 +01:00
97a7c6811c created product's endpoints 2025-11-07 17:41:50 +01:00
f8b3c51435 fix error on CreatePriceEndpoint.cs 2025-11-06 19:25:35 +01:00
a535f8cfeb fix errors in Price's DTO 2025-11-06 18:51:46 +01:00
65b5e6afe3 Merge branch 'feature/CreatingProductEnpoints' into develop 2025-11-06 18:42:39 +01:00
33719b708e Creating of price's endpoints 2025-11-06 18:52:18 +01:00
b00ed36557 Merge remote-tracking branch 'origin/develop' into develop 2025-11-06 17:34:08 +01:00
be0a6a4004 Creating supplier's endpoints 2025-11-06 17:30:03 +01:00
Cristiano
6bc8281a37 AddedAutoMapper 2025-11-06 16:17:35 +01:00
Cristiano
9ff5c038b1 HOTFIX 2025-11-06 16:16:49 +01:00
Cristiano
4bdd8104d8 Fix wrong HTTP method 2025-11-06 16:11:37 +01:00
Cristiano
abc843778f Merge branch 'feature/CreatingDelivererEndpoint' into develop 2025-11-06 16:10:38 +01:00
Cristiano
c0090da9bd Fix unused imports 2025-11-06 16:08:52 +01:00
Cristiano
554ba9b725 Added all the endpoints needed for Deliverer 2025-11-06 15:54:53 +01:00
1c898f9144 Merge branch 'feature/UserEndpoints' into develop 2025-10-27 12:56:04 +01:00
7bb21be0e6 add patch from user for the password 2025-10-27 12:55:25 +01:00
6a4760fb72 Creation user's endpoints 2025-10-27 12:31:25 +01:00
06c64a9f3f add token 2025-10-17 16:53:00 +01:00
aa1c98d649 fix error in api's route 2025-10-17 16:47:34 +01:00
fa72c6d777 creating endpoint WareHouseProduct 2025-10-17 16:23:39 +01:00
59628717d4 rename directory 2025-10-17 15:51:03 +01:00
ff590302e2 Created all endpoints for Quotation and QuotationProduct 2025-10-17 01:05:50 +01:00
45f6baaac3 created quotation's dtos 2025-10-17 00:13:41 +01:00
ef9740d8ff creating PatchPurchaseOrderPurchaseConditionsEndpoint.cs 2025-10-17 00:04:37 +01:00
3ada21adae Creating all setting's endpoints 2025-10-16 23:50:00 +01:00
4f12911263 creating endpoints from PurchaseOrder 2025-10-16 23:28:27 +01:00
8bd7fadabc Merge branch 'feature/CreatingPurchaseProductEndpoints' into develop 2025-10-16 22:55:09 +01:00
e4e6c1c3f7 creating purchaseproduct's endpoint and fix error in dto 2025-10-16 22:53:14 +01:00
791eff9256 added 2025-10-16 19:32:31 +01:00
b4502ae562 editing dto from purchaseproduct 2025-10-16 18:48:55 +01:00
347003c24a updating CreatePurchaseProductEndpoint.cs and GetPurchaseProductDto.cs 2025-10-16 18:40:30 +01:00
31e69aae1a Creating purchaseproduct's endpoint 2025-10-16 17:53:16 +02:00
74b5fa6666 editing dto from PurchaseProduct 2025-10-16 17:24:36 +02:00
b79e07dd8b Adding entities from database and migrating 2025-10-13 18:57:45 +01:00
Cristiano
3192d399cc Fixed name of directory Deliverer 2025-10-11 01:41:16 +02:00
Cristiano
37f6460615 Creating DTO of Deliver and fixing some typing errors 2025-10-11 01:38:41 +02:00
Cristiano
ecd8883d55 Creating DTO of ProductDelivery with flattening 2025-10-11 01:29:02 +02:00
Cristiano
0209dbfc20 Creating DTO of DeliveryNote with flattening 2025-10-11 01:09:09 +02:00
e773e201bd Merge tag 'EditingDatabase' into develop
Merge into master
2025-10-10 10:46:20 +02:00
e336a50c4e Merge branch 'release/EditingDatabase' 2025-10-10 10:46:02 +02:00
e63be6e1f1 Merge branch 'feature/EditingDatabase' into develop 2025-10-10 10:37:37 +02:00
5a36c0ff2f Migration 2025-10-10 10:37:13 +02:00
014646d35c Migration 2025-10-10 10:36:58 +02:00
8371423b16 Editing Product.cs 2025-10-10 10:35:23 +02:00
f7931fbed6 Merge branch 'feature/CreatingQuotationProductDTO' into develop 2025-10-09 19:12:18 +01:00
feb12b8c3b Merge branch 'feature/CreatingPurchaseProductDTO' into develop 2025-10-09 19:11:30 +01:00
5ea5edaea6 Merge branch 'feature/CreatingProductDTO' into develop 2025-10-09 19:10:29 +01:00
aa65139b69 Merge branch 'feature/CreatingSupplierDTO' into develop 2025-10-09 19:10:03 +01:00
9be4fa67e6 Merge branch 'feature/CreatingWareHouseProductDTO' into develop 2025-10-09 19:09:25 +01:00
e69ca1898d delete productsellingprice 2025-10-09 19:06:11 +01:00
15526d1589 delete productsellingprice 2025-10-09 19:04:22 +01:00
a27cb5cf2a fix an error 2025-10-09 19:03:09 +01:00
ddbd662c2a fix an error in product attribute 2025-10-09 19:02:09 +01:00
464869e3ca Creating of all price dto 2025-10-09 19:00:55 +01:00
25d1407bd2 Creating of all product dto 2025-10-09 17:54:28 +02:00
a262fb094c Creating all supplier dto 2025-10-09 17:47:12 +02:00
f0ec7cd4d4 Fix 2025-10-09 17:43:32 +02:00
d0f20e08f0 Fix an error in Setting directory 2025-10-09 17:34:46 +02:00
b1d2d3d1a1 Creating all QuotationProductDTO 2025-10-09 17:25:48 +02:00
64fd223a63 Fix an error in PatchPurchaseProductQuantityDto.cs 2025-10-09 17:09:33 +02:00
59ddb9f7b2 Creating all WareHouseProduct DTO 2025-10-09 17:08:01 +02:00
2d42fa1017 Creating all PurchaseProduct DTO 2025-10-09 16:46:22 +02:00
b859e53f95 Creating all setting Dto 2025-10-09 16:34:12 +02:00
3cc96c4ebf Creating user Dto 2025-10-09 16:25:04 +02:00
6a813fc35a Ajouter README.md 2025-10-08 14:44:42 +02:00
a93d399942 Merge branch 'release/V1' 2025-10-08 11:47:34 +01:00
152 changed files with 18151 additions and 45 deletions

View File

@@ -0,0 +1,6 @@
namespace PyroFetes.DTO.Deliverer.Request;
public class CreateDelivererDto
{
public string? Transporter { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Deliverer.Request;
public class UpdateDelivererDto
{
public int Id { get; set; }
public string? Transporter { get; set; }
}

View File

@@ -0,0 +1,11 @@
using PyroFetes.DTO.DeliveryNote.Response;
namespace PyroFetes.DTO.Deliverer.Response;
public class GetDelivererDto
{
public int Id { get; set; }
public string? Transporter { get; set; }
public List<GetDeliveryNoteDto>? DeliveryNotes { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace PyroFetes.DTO.DeliveryNote.Request;
public class CreateDeliveryNoteDto
{
public string? TrackingNumber { get; set; }
public DateOnly EstimateDeliveryDate { get; set; }
public DateOnly ExpeditionDate { get; set; }
public int DelivererId { get; set; }
public Dictionary<int,int>? ProductQuantities { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.DeliveryNote.Request;
public class PatchDeliveryNoteRealDeliveryDateDto
{
public int Id { get; set; }
public DateOnly RealDeliveryDate { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace PyroFetes.DTO.DeliveryNote.Request;
public class UpdateDeliveryNoteDto
{
public int Id { get; set; }
public string? TrackingNumber { get; set; }
public DateOnly EstimateDeliveryDate { get; set; }
public DateOnly ExpeditionDate { get; set; }
public DateOnly? RealDeliveryDate { get; set; }
public int DelivererId { get; set; }
}

View File

@@ -0,0 +1,17 @@
using PyroFetes.DTO.ProductDelivery.Response;
namespace PyroFetes.DTO.DeliveryNote.Response;
public class GetDeliveryNoteDto
{
public int Id { get; set; }
public string? TrackingNumber { get; set; }
public DateOnly EstimateDeliveryDate { get; set; }
public DateOnly ExpeditionDate { get; set; }
public DateOnly? RealDeliveryDate { get; set; }
public int DelivererId { get; set; }
public string? DelivererTransporter { get; set; }
public List<GetProductDeliveryDto>? Products { get; set; }
}

View File

@@ -0,0 +1,27 @@
namespace PyroFetes.DTO.Price.Request;
public class CreatePriceDto
{
public decimal SellingPrice { get; set; }
public int? SupplierId { get; set; }
public string? SupplierName { get; set; }
public string? SupplierEmail { get; set; }
public string? SupplierPhone { get; set; }
public string? SupplierAddress { get; set; }
public string? SupplierZipCode { get; set; }
public string? SupplierCity { get; set; }
public int SupplierDeliveryDelay { get; set; }
public int? ProductId { get; set; }
public string? ProductReferences { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public int ProductCaliber { get; set; }
public string? ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.Price.Request;
public class PatchPriceSellingPriceDto
{
public int ProductId { get; set; }
public int SupplierId { get; set; }
public decimal SellingPrice { get; set; }
}

View File

@@ -0,0 +1,28 @@
namespace PyroFetes.DTO.Price.Request;
public class UpdatePriceDto
{
public int Id { get; set; }
public decimal SellingPrice { get; set; }
public int SupplierId { get; set; }
public string? SupplierName { get; set; }
public string? SupplierEmail { get; set; }
public string? SupplierPhone { get; set; }
public string? SupplierAddress { get; set; }
public int SupplierZipCode { get; set; }
public string? SupplierCity { get; set; }
public int SupplierDeliveryDelay { get; set; }
public int ProductId { get; set; }
public string? ProductReferences { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public decimal ProductCaliber { get; set; }
public int ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,28 @@
namespace PyroFetes.DTO.Price.Response;
public class GetPriceDto
{
public int Id { get; set; }
public decimal SellingPrice { get; set; }
public int SupplierId { get; set; }
public string? SupplierName { get; set; }
public string? SupplierEmail { get; set; }
public string? SupplierPhone { get; set; }
public string? SupplierAddress { get; set; }
public int SupplierZipCode { get; set; }
public string? SupplierCity { get; set; }
public int SupplierDeliveryDelay { get; set; }
public int ProductId { get; set; }
public string? ProductReferences { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public decimal ProductCaliber { get; set; }
public int ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,15 @@
namespace PyroFetes.DTO.Product.Request;
public class CreateProductDto
{
public string? References { get; set; }
public string? Name { get; set; }
public decimal Duration {get; set;}
public int Caliber { get; set; }
public string? ApprovalNumber { get; set; }
public decimal Weight { get; set; }
public decimal Nec { get; set; }
public string? Image { get; set; }
public string? Link { get; set; }
public int MinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Product.Request;
public class PatchProductMinimalStockDto
{
public int Id { get; set; }
public int MinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,16 @@
namespace PyroFetes.DTO.Product.Request;
public class UpdateProductDto
{
public int Id { get; set; }
public string? References { get; set; }
public string? Name { get; set; }
public decimal Duration {get; set;}
public int Caliber { get; set; }
public string? ApprovalNumber { get; set; }
public decimal Weight { get; set; }
public decimal Nec { get; set; }
public string? Image { get; set; }
public string? Link { get; set; }
public int MinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,16 @@
namespace PyroFetes.DTO.Product.Response;
public class GetProductDto
{
public int Id { get; set; }
public string? References { get; set; }
public string? Name { get; set; }
public decimal Duration {get; set;}
public int Caliber { get; set; }
public string? ApprovalNumber { get; set; }
public decimal Weight { get; set; }
public decimal Nec { get; set; }
public string? Image { get; set; }
public string? Link { get; set; }
public int MinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.ProductDelivery.Request;
public class CreateProductDeliveryDto
{
public int ProductId { get; set; }
public int DeliveryNoteId { get; set; }
public int Quantity { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.ProductDelivery.Request;
public class UpdateProductDeliveryDto
{
public int Quantity { get; set; }
public int ProductId { get; set; }
public int DeliveryNoteId { get; set; }
}

View File

@@ -0,0 +1,28 @@
namespace PyroFetes.DTO.ProductDelivery.Response;
public class GetProductDeliveryDto
{
public int ProductId { get; set; }
public int ProductReference { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public decimal ProductCaliber { get; set; }
public int ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
public int DeliveryNoteId { get; set; }
public string? DeliveryNoteTrackingNumber { get; set; }
public DateOnly DeliveryNoteEstimateDeliveryDate { get; set; }
public DateOnly DeliveryNoteExpeditionDate { get; set; }
public DateOnly? DeliveryNoteRealDeliveryDate { get; set; }
public int DeliveryNoteDeliverId { get; set; }
public string? DeliveryNoteDeliverTransporter { get; set; }
public int Quantity { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.PurchaseOrder.Request;
public class PatchPurchaseOrderPurchaseConditionsDto
{
public int Id { get; set; }
public string? PurchaseConditions { get; set; }
}

View File

@@ -0,0 +1,10 @@
using PyroFetes.DTO.PurchaseProduct.Response;
namespace PyroFetes.DTO.PurchaseOrder.Response;
public class GetPurchaseOrderDto
{
public int Id { get; set; }
public string? PurchaseConditions { get; set; }
public List<GetPurchaseProductDto>? GetPurchaseProductDto { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace PyroFetes.DTO.PurchaseProduct.Request;
public class CreatePurchaseProductDto
{
public int Quantity { get; set; }
public int ProductId { get; set; }
public int PurchaseOrderId { get; set; }
public string? PurchaseOrderPurchaseConditions { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.PurchaseProduct.Request;
public class PatchPurchaseProductQuantityDto
{
public int ProductId { get; set; }
public int PurchaseOrderId { get; set; }
public int Quantity { get; set; }
}

View File

@@ -0,0 +1,22 @@
namespace PyroFetes.DTO.PurchaseProduct.Request;
public class UpdatePurchaseProductDto
{
public int ProductId { get; set; }
public int PurchaseOrderId { get; set; }
public int Quantity { get; set; }
public int ProductReferences { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public decimal ProductCaliber { get; set; }
public int ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
public string? PurchaseOrderPurchaseConditions { get; set; }
}

View File

@@ -0,0 +1,21 @@
namespace PyroFetes.DTO.PurchaseProduct.Response;
public class GetPurchaseProductDto
{
public int ProductId { get; set; }
public string? ProductReferences { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public decimal ProductCaliber { get; set; }
public int ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
public int PurchaseOrderId { get; set; }
public string? PurchaseOrderPurchaseConditions { get; set; }
public int Quantity { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Quotation.Request;
public class PatchQuotationConditionsSaleDto
{
public int Id { get; set; }
public string? ConditionsSale { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Quotation.Request;
public class PatchQuotationMessageDto
{
public int Id { get; set; }
public string? Message { get; set; }
}

View File

@@ -0,0 +1,11 @@
using PyroFetes.DTO.QuotationProduct.Response;
namespace PyroFetes.DTO.Quotation.Response;
public class GetQuotationDto
{
public int Id { get; set; }
public string? Message { get; set; }
public string? ConditionsSale { get; set; }
public List<GetQuotationProductDto>? GetQuotationProductDto { get; set; }
}

View File

@@ -0,0 +1,22 @@
namespace PyroFetes.DTO.QuotationProduct.Request;
public class CreateQuotationProductDto
{
public int Quantity { get; set; }
public int QuotationId { get; set; }
public string? QuotationMessage { get; set; }
public string? QuotationConditionsSale { get; set; }
public int ProductId { get; set; }
public int ProductReferences { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public decimal ProductCaliber { get; set; }
public int ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.QuotationProduct.Request;
public class PatchQuotationProductQuantityDto
{
public int ProductId { get; set; }
public int QuotationId { get; set; }
public int Quantity { get; set; }
}

View File

@@ -0,0 +1,23 @@
namespace PyroFetes.DTO.QuotationProduct.Request;
public class UpdateQuotationProductDto
{
public int Id { get; set; }
public int Quantity { get; set; }
public int QuotationId { get; set; }
public string? QuotationMessage { get; set; }
public string? QuotationConditionsSale { get; set; }
public int ProductId { get; set; }
public int ProductReferences { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public decimal ProductCaliber { get; set; }
public int ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,22 @@
namespace PyroFetes.DTO.QuotationProduct.Response;
public class GetQuotationProductDto
{
public int Quantity { get; set; }
public int QuotationId { get; set; }
public string? QuotationMessage { get; set; }
public string? QuotationConditionsSale { get; set; }
public int ProductId { get; set; }
public string? ProductReferences { get; set; }
public string? ProductName { get; set; }
public decimal ProductDuration {get; set;}
public decimal ProductCaliber { get; set; }
public int ProductApprovalNumber { get; set; }
public decimal ProductWeight { get; set; }
public decimal ProductNec { get; set; }
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.SettingDTO.Request;
public class CreateSettingDto
{
public string? ElectronicSignature { get; set; }
public string? Logo { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.SettingDTO.Request;
public class PatchSettingElectronicSignatureDto
{
public int Id { get; set; }
public string? ElectronicSignature { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.SettingDTO.Request;
public class PatchSettingLogoDto
{
public int Id { get; set; }
public string? Logo { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.SettingDTO.Response;
public class GetSettingDto
{
public int Id { get; set; }
public string? ElectronicSignature { get; set; }
public string? Logo { get; set; }
}

View File

@@ -0,0 +1,12 @@
namespace PyroFetes.DTO.Supplier.Request;
public class CreateSupplierDto
{
public string? Name { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string? Address { get; set; }
public string? ZipCode { get; set; }
public string? City { get; set; }
public int DeliveryDelay { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.Supplier.Request;
public class PatchSupplierDeliveryDelayDto
{
public int Id { get; set; }
public int DeliveryDelay { get; set; }
}

View File

@@ -0,0 +1,13 @@
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? Phone { get; set; }
public string? Address { get; set; }
public string? ZipCode { get; set; }
public string? City { get; set; }
public int DeliveryDelay { get; set; }
}

View File

@@ -0,0 +1,13 @@
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? Phone { get; set; }
public string? Address { get; set; }
public string? ZipCode { get; set; }
public string? City { get; set; }
public int DeliveryDelay { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.User.Request;
public class ConnectUserDto
{
public string? Name { get; set; }
public string? Password { get; set; }
}

View File

@@ -0,0 +1,9 @@
namespace PyroFetes.DTO.User.Request;
public class CreateUserDto
{
public string? Name { get; set; }
public string? Password { get; set; }
public string? Fonction { get; set; }
public string? Email { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.User.Request;
public class PatchUserPasswordDto
{
public int Id { get; set; }
public string? Password { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace PyroFetes.DTO.User.Request;
public class UpdateUserDto
{
public int Id { get; set; }
public string? Name { get; set; }
public string? Password { get; set; }
public string? Fonction { get; set; }
public string? Email { get; set; }
}

View File

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

View File

@@ -0,0 +1,11 @@
namespace PyroFetes.DTO.User.Response;
public class GetUserDto
{
public int Id { get; set; }
public string? Name { get; set; }
public string? Password { get; set; }
public string? Salt { get; set; }
public string? Fonction { get; set; }
public string? Email { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.WareHouseProduct.Request;
public class PatchWareHouseProductQuantityDto
{
public int WareHouseId { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace PyroFetes.DTO.WareHouseProduct.Response;
public class GetTotalQuantityDto
{
public int ProductId { get; set; }
public int TotalQuantity { get; set; }
}

View File

@@ -0,0 +1,8 @@
namespace PyroFetes.DTO.WareHouseProduct.Response;
public class GetWareHouseProductDto
{
public int Quantity { get; set; }
public int WareHouseId { get; set; }
public int ProductId { get; set; }
}

View File

@@ -0,0 +1,30 @@
using FastEndpoints;
using PyroFetes.DTO.Deliverer.Request;
using PyroFetes.DTO.Deliverer.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Deliverers;
public class CreateDelivererEndpoint(
DeliverersRepository deliverersRepository,
AutoMapper.IMapper mapper) : Endpoint<CreateDelivererDto, GetDelivererDto>
{
public override void Configure()
{
Post("/deliverers");
AllowAnonymous();
}
public override async Task HandleAsync(CreateDelivererDto req, CancellationToken ct)
{
Deliverer newDeliverer = new Deliverer()
{
Transporter = req.Transporter,
};
await deliverersRepository.AddAsync(newDeliverer, ct);
await Send.OkAsync(mapper.Map<GetDelivererDto>(newDeliverer), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Deliverers;
namespace PyroFetes.Endpoints.Deliverers;
public class DeleteDelivererRequest
{
public int DelivererId { get; set; }
}
public class DeleteDelivererEndpoint(DeliverersRepository deliverersRepository) : Endpoint<DeleteDelivererRequest>
{
public override void Configure()
{
Delete("/deliverers/{@id}", x=>new {x.DelivererId});
AllowAnonymous();
}
public override async Task HandleAsync(DeleteDelivererRequest req, CancellationToken ct)
{
Deliverer? deliverer = await deliverersRepository.FirstOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct);
if (deliverer == null)
{
await Send.NotFoundAsync(ct);
return;
}
await deliverersRepository.DeleteAsync(deliverer, ct);
await Send.OkAsync(ct);
}
}

View File

@@ -0,0 +1,23 @@
using AutoMapper.QueryableExtensions;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Deliverer.Response;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Deliverers;
public class GetAllDelivererEndpoint(DeliverersRepository deliverersRepository) : EndpointWithoutRequest<List<GetDelivererDto>>
{
public override void Configure()
{
Get("/deliverers");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await deliverersRepository.ProjectToListAsync<GetDelivererDto>(ct), ct);
}
}

View File

@@ -0,0 +1,39 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Deliverer.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Deliverers;
namespace PyroFetes.Endpoints.Deliverers;
public class GetDelivererRequest
{
public int DelivererId { get; set; }
}
public class GetDelivererEndpoint(
DeliverersRepository deliverersRepository,
AutoMapper.IMapper mapper) : Endpoint<GetDelivererRequest, GetDelivererDto>
{
public override void Configure()
{
Get("/deliverers/{@id}", x=>new {x.DelivererId});
AllowAnonymous();
}
public override async Task HandleAsync(GetDelivererRequest req, CancellationToken ct)
{
Deliverer? deliverer = await deliverersRepository.FirstOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct);
if (deliverer == null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetDelivererDto>(deliverer), ct);
}
}

View File

@@ -0,0 +1,39 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Deliverer.Request;
using PyroFetes.DTO.Deliverer.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Deliverers;
namespace PyroFetes.Endpoints.Deliverers;
public class UpdateDelivererEndpoint(
DeliverersRepository deliverersRepository,
AutoMapper.IMapper mapper) : Endpoint<UpdateDelivererDto, GetDelivererDto>
{
public override void Configure()
{
Put("/deliverers/{@id}", x=>new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(UpdateDelivererDto req, CancellationToken ct)
{
Deliverer? deliverer = await deliverersRepository.FirstOrDefaultAsync(new GetDelivererByIdSpec(req.Id), ct);
if (deliverer == null)
{
await Send.NotFoundAsync(ct);
return;
}
deliverer.Transporter = req.Transporter;
await deliverersRepository.UpdateAsync(deliverer,ct);
await Send.OkAsync(mapper.Map<GetDelivererDto>(deliverer), ct);
}
}

View File

@@ -0,0 +1,68 @@
using FastEndpoints;
using PyroFetes.DTO.DeliveryNote.Request;
using PyroFetes.DTO.DeliveryNote.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Deliverers;
using PyroFetes.Specifications.Products;
namespace PyroFetes.Endpoints.DeliveryNotes;
public class CreateDeliveryNoteEndpoint(
DeliveryNotesRepository deliveryNotesRepository,
DeliverersRepository deliverersRepository,
ProductsRepository productsRepository,
ProductDeliveriesRepository productDeliveriesRepository,
AutoMapper.IMapper mapper) : Endpoint<CreateDeliveryNoteDto, GetDeliveryNoteDto>
{
public override void Configure()
{
Post("/deliveryNotes");
AllowAnonymous();
}
public override async Task HandleAsync(CreateDeliveryNoteDto req, CancellationToken ct)
{
Deliverer? deliverer = await deliverersRepository.FirstOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct);
if (deliverer == null)
{
await Send.StringAsync("No deliverer found", 404, cancellation: ct);
return;
}
//Creating the Delivery Note
DeliveryNote newDeliveryNote = new DeliveryNote()
{
TrackingNumber = req.TrackingNumber,
EstimateDeliveryDate = req.EstimateDeliveryDate,
ExpeditionDate = req.ExpeditionDate,
DelivererId = req.DelivererId,
Deliverer = deliverer,
};
await deliveryNotesRepository.AddAsync(newDeliveryNote, ct);
foreach (var productQuantity in req.ProductQuantities!)
{
Product? product =
await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(productQuantity.Key), ct);
if (product != null)
{
ProductDelivery productDelivery = new ProductDelivery()
{
DeliveryNote = newDeliveryNote,
Quantity = productQuantity.Value,
Product = product,
DeliveryNoteId = newDeliveryNote.Id
};
await productDeliveriesRepository.AddAsync(productDelivery, ct);
}
}
await Send.OkAsync(mapper.Map<GetDeliveryNoteDto>(newDeliveryNote), ct);
}
}

View File

@@ -0,0 +1,20 @@
using FastEndpoints;
using PyroFetes.DTO.DeliveryNote.Response;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.DeliveryNotes;
public class GetAllDeliveryNoteEndpoint(DeliveryNotesRepository deliveryNotesRepository) : EndpointWithoutRequest<List<GetDeliveryNoteDto>>
{
public override void Configure()
{
Get("/deliveryNotes");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await deliveryNotesRepository.ProjectToListAsync<GetDeliveryNoteDto>(ct), ct);
}
}

View File

@@ -0,0 +1,35 @@
using FastEndpoints;
using PyroFetes.DTO.DeliveryNote.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.DeliveryNotes;
namespace PyroFetes.Endpoints.DeliveryNotes;
public class GetDeliveryNoteRequest
{
public int DeliveryNoteId { get; set; }
}
public class GetDeliveryNoteEndpoint(
DeliveryNotesRepository deliveryNotesRepository,
AutoMapper.IMapper mapper) : Endpoint<GetDeliveryNoteRequest, GetDeliveryNoteDto>
{
public override void Configure()
{
Get("/deliveryNotes/{@id}", x=> new {x.DeliveryNoteId});
AllowAnonymous();
}
public override async Task HandleAsync(GetDeliveryNoteRequest req, CancellationToken ct)
{
DeliveryNote? deliveryNote = await deliveryNotesRepository.FirstOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.DeliveryNoteId), ct);
if (deliveryNote == null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetDeliveryNoteDto>(deliveryNote), ct);
}
}

View File

@@ -0,0 +1,39 @@
using FastEndpoints;
using PyroFetes.DTO.DeliveryNote.Request;
using PyroFetes.DTO.DeliveryNote.Response;
using PyroFetes.DTO.PurchaseProduct.Request;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Deliverers;
using PyroFetes.Specifications.DeliveryNotes;
namespace PyroFetes.Endpoints.DeliveryNotes;
public class PatchRealDeliveryDateEndpoint(
DeliveryNotesRepository deliveryNotesRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchDeliveryNoteRealDeliveryDateDto, GetDeliveryNoteDto>
{
public override void Configure()
{
Patch("/deliveryNotes/{@id}", x=> new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(PatchDeliveryNoteRealDeliveryDateDto req, CancellationToken ct)
{
DeliveryNote? deliveryNoteToPath =
await deliveryNotesRepository.FirstOrDefaultAsync(new GetDeliveryNoteByIdSpec(req.Id),ct);
if (deliveryNoteToPath == null)
{
await Send.NotFoundAsync(ct);
return;
}
deliveryNoteToPath.RealDeliveryDate = req.RealDeliveryDate;
await deliveryNotesRepository.UpdateAsync(deliveryNoteToPath, ct);
await Send.OkAsync(mapper.Map<GetDeliveryNoteDto>(deliveryNoteToPath), ct);
}
}

View File

@@ -0,0 +1,84 @@
using FastEndpoints;
using PyroFetes.DTO.Price.Request;
using PyroFetes.DTO.Price.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Prices;
using PyroFetes.Specifications.Products;
using PyroFetes.Specifications.Suppliers;
namespace PyroFetes.Endpoints.Prices;
public class CreatePriceEndpoint(
SuppliersRepository suppliersRepository,
ProductsRepository productsRepository,
PricesRepository pricesRepository,
AutoMapper.IMapper mapper) : Endpoint<CreatePriceDto, GetPriceDto>
{
public override void Configure()
{
Post("/prices");
AllowAnonymous();
}
public override async Task HandleAsync(CreatePriceDto req, CancellationToken ct)
{
// Gestion du fournisseur
Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.SupplierId), ct);
if (supplier == null)
{
supplier = new Supplier()
{
Name = req.SupplierName,
Email = req.SupplierEmail,
Phone = req.SupplierPhone,
Address = req.SupplierAddress,
City = req.SupplierCity,
ZipCode = req.SupplierZipCode,
DeliveryDelay = req.SupplierDeliveryDelay
};
await suppliersRepository.AddAsync(supplier, ct);
}
// Gestion du produit
Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct);
if (product == null)
{
product = new Product()
{
Reference = req.ProductReferences,
Name = req.ProductName,
Duration = req.ProductDuration,
Caliber = req.ProductCaliber,
ApprovalNumber = req.ProductApprovalNumber,
Weight = req.ProductWeight,
Nec = req.ProductNec,
Image = req.ProductImage,
Link = req.ProductLink,
MinimalQuantity = req.ProductMinimalQuantity
};
await productsRepository.AddAsync(product, ct);
}
// Vérifie si le prix existe déjà pour ce fournisseur et produit
Price? existingPrice = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId), ct);
if (existingPrice != null)
{
await Send.StringAsync("Le fournisseur a déjà un prix pour ce produit.", 400, cancellation: ct);
return;
}
// Création du prix
var priceAdded = new Price()
{
SellingPrice = req.SellingPrice,
SupplierId = supplier.Id,
ProductId = product.Id
};
await pricesRepository.AddAsync(priceAdded, ct);
await Send.OkAsync(mapper.Map<GetPriceDto>(priceAdded), ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Prices;
namespace PyroFetes.Endpoints.Prices;
public class DeletePriceRequest
{
public int ProductId { get; set; }
public int SupplierId { get; set; }
}
public class DeletePriceEndpoint(PricesRepository pricesRepository) : Endpoint<DeletePriceRequest>
{
public override void Configure()
{
Delete("/prices/{@ProductId}/{@SupplierId}", x => new {x.ProductId, x.SupplierId});
AllowAnonymous();
}
public override async Task HandleAsync(DeletePriceRequest req, CancellationToken ct)
{
Price? price = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId,req.SupplierId), ct);
if (price == null)
{
await Send.NotFoundAsync(ct);
return;
}
await pricesRepository.DeleteAsync(price, ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using PyroFetes.DTO.Price.Request;
using PyroFetes.DTO.Price.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Prices;
namespace PyroFetes.Endpoints.Prices;
public class PatchPriceEndpoint(
PricesRepository pricesRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchPriceSellingPriceDto, GetPriceDto>
{
public override void Configure()
{
Patch("/prices/{@ProductId}/{@SupplierId}/SellingPrice", x => new { x.ProductId, x.SupplierId });
AllowAnonymous();
}
public override async Task HandleAsync(PatchPriceSellingPriceDto req, CancellationToken ct)
{
Price? price = await pricesRepository.FirstOrDefaultAsync(new GetPriceByProductIdAndSupplierIdSpec(req.ProductId, req.SupplierId),ct);
if (price == null)
{
await Send.NotFoundAsync(ct);
return;
}
price.SellingPrice = req.SellingPrice;
await pricesRepository.UpdateAsync(price, ct);
await Send.OkAsync(mapper.Map<GetPriceDto>(price), ct);
}
}

View File

@@ -0,0 +1,21 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Products;
public class GetAllProductsEndpoint(ProductsRepository productsRepository) : EndpointWithoutRequest<List<GetProductDto>>
{
public override void Configure()
{
Get("/products");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await productsRepository.ProjectToListAsync<GetProductDto>(ct), ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Products;
namespace PyroFetes.Endpoints.Products;
public class GetProductRequest
{
public int Id { get; set; }
}
public class GetProductEndpoint(
ProductsRepository productsRepository,
AutoMapper.IMapper mapper) : Endpoint<GetProductRequest, GetProductDto>
{
public override void Configure()
{
Get("/products/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetProductRequest req, CancellationToken ct)
{
Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.Id), ct);
if (product == null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetProductDto>(product), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Products;
namespace PyroFetes.Endpoints.Products;
public class PatchProductMinimalStockEndpoint(
ProductsRepository productsRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchProductMinimalStockDto, GetProductDto>
{
public override void Configure()
{
Patch("/products/{@Id}/MinimalStock", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(PatchProductMinimalStockDto req, CancellationToken ct)
{
Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.Id), ct);
if (product == null)
{
await Send.NotFoundAsync(ct);
return;
}
product.MinimalQuantity = req.MinimalQuantity;
await productsRepository.UpdateAsync(product, ct);
await Send.OkAsync(mapper.Map<GetProductDto>(product), ct);
}
}

View File

@@ -0,0 +1,46 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.Product.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Products;
namespace PyroFetes.Endpoints.Products;
public class UpdateProductEndpoint(
ProductsRepository productsRepository,
AutoMapper.IMapper mapper) : Endpoint<UpdateProductDto, GetProductDto>
{
public override void Configure()
{
Put("/products/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(UpdateProductDto req, CancellationToken ct)
{
Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.Id), ct);
if (product == null)
{
await Send.NotFoundAsync(ct);
return;
}
product.Reference = 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.Image = req.Image;
product.Link = req.Link;
product.MinimalQuantity = req.MinimalQuantity;
await productsRepository.UpdateAsync(product, ct);
await Send.OkAsync(mapper.Map<GetProductDto>(product), ct);
}
}

View File

@@ -0,0 +1,43 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.PurchaseOrders;
namespace PyroFetes.Endpoints.PurchaseOrders;
public class DeletePurchaseOrderRequest
{
public int Id { get; set; }
}
public class DeletePurchaseOrderEndpoint(
PurchaseOrdersRepository purchaseOrdersRepository,
PurchaseProductsRepository purchaseProductsRepository) : Endpoint<DeletePurchaseOrderRequest>
{
public override void Configure()
{
Delete("/purchaseOrders/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(DeletePurchaseOrderRequest req, CancellationToken ct)
{
PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct);
if (purchaseOrder == null)
{
await Send.NotFoundAsync(ct);
return;
}
if (purchaseOrder.PurchaseProducts != null && purchaseOrder.PurchaseProducts.Any())
{
await purchaseProductsRepository.DeleteRangeAsync(purchaseOrder.PurchaseProducts, ct);
}
await purchaseOrdersRepository.DeleteAsync(purchaseOrder, ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,21 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.PurchaseOrders;
public class GetAllPurchaseOrderEndpoint(PurchaseOrdersRepository purchaseOrdersRepository) : EndpointWithoutRequest<List<GetPurchaseOrderDto>>
{
public override void Configure()
{
Get("/purchaseOrders");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await purchaseOrdersRepository.ProjectToListAsync<GetPurchaseOrderDto>(ct), ct);
}
}

View File

@@ -0,0 +1,38 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.PurchaseOrders;
namespace PyroFetes.Endpoints.PurchaseOrders;
public class GetPurchaseOrderRequest
{
public int Id { get; set; }
}
public class GetPurchaseOrderEndpoint(
PurchaseOrdersRepository purchaseOrdersRepository,
AutoMapper.IMapper mapper) : Endpoint<GetPurchaseOrderRequest, GetPurchaseOrderDto>
{
public override void Configure()
{
Get("/purchaseOrders/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetPurchaseOrderRequest req, CancellationToken ct)
{
PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct);
if (purchaseOrder == null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetPurchaseOrderDto>(purchaseOrder), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseOrder.Request;
using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.PurchaseOrders;
namespace PyroFetes.Endpoints.PurchaseOrders;
public class PatchPurchaseOrderPurchaseConditionsEndpoint(
PurchaseOrdersRepository purchaseOrdersRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchPurchaseOrderPurchaseConditionsDto, GetPurchaseOrderDto>
{
public override void Configure()
{
Patch("/purchaseOrders/{@Id}/PurchaseConditions", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(PatchPurchaseOrderPurchaseConditionsDto req, CancellationToken ct)
{
PurchaseOrder? purchaseOrder = await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.Id), ct);
if (purchaseOrder == null)
{
await Send.NotFoundAsync(ct);
return;
}
purchaseOrder.PurchaseConditions = req.PurchaseConditions;
await purchaseOrdersRepository.UpdateAsync(purchaseOrder, ct);
await Send.OkAsync(mapper.Map<GetPurchaseOrderDto>(purchaseOrder), ct);
}
}

View File

@@ -0,0 +1,56 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseProduct.Request;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Products;
using PyroFetes.Specifications.PurchaseOrders;
namespace PyroFetes.Endpoints.PurchaseProducts;
public class CreatePurchaseProductEndpoint(
ProductsRepository productsRepository,
PurchaseOrdersRepository purchaseOrdersRepository,
PurchaseProductsRepository purchaseProductsRepository,
AutoMapper.IMapper mapper) : Endpoint<CreatePurchaseProductDto, GetPurchaseProductDto>
{
public override void Configure()
{
Post("/purchaseProducts");
AllowAnonymous();
}
public override async Task HandleAsync(CreatePurchaseProductDto req, CancellationToken ct)
{
Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct);
if (product == null)
{
await Send.NotFoundAsync(ct);
return;
}
PurchaseOrder? purchaseOrder =
await purchaseOrdersRepository.FirstOrDefaultAsync(new GetPurchaseOrderByIdSpec(req.PurchaseOrderId), ct);
if (purchaseOrder == null)
{
purchaseOrder = new PurchaseOrder()
{
PurchaseConditions = req.PurchaseOrderPurchaseConditions ?? "Conditions non précisées"
};
await purchaseOrdersRepository.AddAsync(purchaseOrder, ct);
}
PurchaseProduct purchaseProduct = new PurchaseProduct()
{
ProductId = product.Id,
PurchaseOrderId = purchaseOrder.Id,
Quantity = req.Quantity
};
await purchaseProductsRepository.AddAsync(purchaseProduct, ct);
await Send.OkAsync(mapper.Map<GetPurchaseProductDto>(purchaseProduct), ct);
}
}

View File

@@ -0,0 +1,38 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.PurchaseProducts;
namespace PyroFetes.Endpoints.PurchaseProducts;
public class DeletePurchaseProductRequest
{
public int ProductId { get; set; }
public int PurchaseOrderId { get; set; }
}
public class DeletePurchaseProductEndpoint(PurchaseProductsRepository purchaseProductsRepository) : Endpoint<DeletePurchaseProductRequest>
{
public override void Configure()
{
Delete("/purchaseProducts/{@ProductId}/{@PurchaseOrderId}", x => new {x.ProductId, x.PurchaseOrderId});
AllowAnonymous();
}
public override async Task HandleAsync(DeletePurchaseProductRequest req, CancellationToken ct)
{
PurchaseProduct? purchaseProduct = await purchaseProductsRepository.FirstOrDefaultAsync(
new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(req.ProductId, req.PurchaseOrderId), ct);
if (purchaseProduct == null)
{
await Send.NotFoundAsync(ct);
return;
}
await purchaseProductsRepository.DeleteAsync(purchaseProduct, ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,38 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.PurchaseProduct.Request;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.PurchaseProducts;
namespace PyroFetes.Endpoints.PurchaseProducts;
public class PatchPurchaseProductQuantityEndpoint(
PurchaseProductsRepository purchaseProductsRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchPurchaseProductQuantityDto, GetPurchaseProductDto>
{
public override void Configure()
{
Patch("/purchaseProducts/{@ProductId}/{@PurchaseOrderId}/Quantity", x => new { x.ProductId, x.PurchaseOrderId });
AllowAnonymous();
}
public override async Task HandleAsync(PatchPurchaseProductQuantityDto req, CancellationToken ct)
{
PurchaseProduct? purchaseProduct =
await purchaseProductsRepository.FirstOrDefaultAsync(
new GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(req.ProductId, req.PurchaseOrderId), ct);
if (purchaseProduct == null)
{
await Send.NotFoundAsync(ct);
return;
}
purchaseProduct.Quantity = req.Quantity;
await purchaseProductsRepository.UpdateAsync(purchaseProduct, ct);
await Send.OkAsync(mapper.Map<GetPurchaseProductDto>(purchaseProduct), ct);
}
}

View File

@@ -0,0 +1,58 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.QuotationProduct.Request;
using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Products;
using PyroFetes.Specifications.Quotations;
namespace PyroFetes.Endpoints.QuotationProducts;
public class CreateQuotationProductEndpoint(
QuotationProductsRepository quotationProductsRepository,
ProductsRepository productsRepository,
QuotationsRepository quotationsRepository,
AutoMapper.IMapper mapper) : Endpoint<CreateQuotationProductDto, GetQuotationProductDto>
{
public override void Configure()
{
Post("/quotationProducts");
AllowAnonymous();
}
public override async Task HandleAsync(CreateQuotationProductDto req, CancellationToken ct)
{
Product? product = await productsRepository.FirstOrDefaultAsync(new GetProductByIdSpec(req.ProductId), ct);
if (product == null)
{
await Send.NotFoundAsync(ct);
return;
}
Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.QuotationId), ct);
if (quotation == null)
{
quotation = new Quotation()
{
Message = req.QuotationMessage ?? "",
ConditionsSale = req.QuotationConditionsSale,
};
await quotationsRepository.AddAsync(quotation, ct);
}
QuotationProduct quotationProduct = new QuotationProduct()
{
ProductId = product.Id,
QuotationId = quotation.Id,
Quantity = req.Quantity
};
await quotationProductsRepository.AddAsync(quotationProduct, ct);
await Send.OkAsync(mapper.Map<GetQuotationProductDto>(quotationProduct), ct);
}
}

View File

@@ -0,0 +1,39 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.QuotationProducts;
namespace PyroFetes.Endpoints.QuotationProducts;
public class DeleteQuotationProductRequest
{
public int ProductId { get; set; }
public int QuotationId { get; set; }
}
public class DeleteQuotationProductEndpoint(QuotationProductsRepository quotationProductsRepository) : Endpoint<DeleteQuotationProductRequest>
{
public override void Configure()
{
Delete("/quotationProducts/{@ProductId}/{@QuotationId}", x => new {x.ProductId, x.QuotationId});
AllowAnonymous();
}
public override async Task HandleAsync(DeleteQuotationProductRequest req, CancellationToken ct)
{
QuotationProduct? quotationProduct =
await quotationProductsRepository.FirstOrDefaultAsync(
new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct);
if (quotationProduct == null)
{
await Send.NotFoundAsync(ct);
return;
}
await quotationProductsRepository.DeleteAsync(quotationProduct, ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.QuotationProduct.Request;
using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.QuotationProducts;
namespace PyroFetes.Endpoints.QuotationProducts;
public class PatchQuotationProductQuantityEndpoint(
QuotationProductsRepository quotationProductsRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchQuotationProductQuantityDto, GetQuotationProductDto>
{
public override void Configure()
{
Patch("/quotationProducts/{@ProductId}/{@QuotationId}/Quantity", x => new { x.ProductId, x.QuotationId });
AllowAnonymous();
}
public override async Task HandleAsync(PatchQuotationProductQuantityDto req, CancellationToken ct)
{
QuotationProduct? quotationProduct =
await quotationProductsRepository.FirstOrDefaultAsync(
new GetQuotationProductByProductIdAndQuotationIdSpec(req.ProductId, req.QuotationId), ct);
if (quotationProduct == null)
{
await Send.NotFoundAsync(ct);
return;
}
quotationProduct.Quantity = req.Quantity;
await quotationProductsRepository.UpdateAsync(quotationProduct, ct);
await Send.OkAsync(mapper.Map<GetQuotationProductDto>(quotationProduct), ct);
}
}

View File

@@ -0,0 +1,43 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Quotations;
namespace PyroFetes.Endpoints.Quotations;
public class DeleteQuotationRequest
{
public int Id { get; set; }
}
public class DeleteQuotationEndpoint(
QuotationsRepository quotationsRepository,
QuotationProductsRepository quotationProductsRepository) : Endpoint<DeleteQuotationRequest>
{
public override void Configure()
{
Delete("/quotations/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(DeleteQuotationRequest req, CancellationToken ct)
{
Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct);
if (quotation == null)
{
await Send.NotFoundAsync(ct);
return;
}
if (quotation.QuotationProducts != null && quotation.QuotationProducts.Any())
{
await quotationProductsRepository.DeleteRangeAsync(quotation.QuotationProducts, ct);
}
await quotationsRepository.DeleteAsync(quotation, ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,22 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Quotations;
public class GetAllQuotationEndpoint(QuotationsRepository quotationsRepository) : EndpointWithoutRequest<List<GetQuotationDto>>
{
public override void Configure()
{
Get("/quotations");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await quotationsRepository.ProjectToListAsync<GetQuotationDto>(ct), ct);
}
}

View File

@@ -0,0 +1,38 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Quotations;
namespace PyroFetes.Endpoints.Quotations;
public class GetQuotationRequest
{
public int Id { get; set; }
}
public class GetQuotationEndpoint(
QuotationsRepository quotationsRepository,
AutoMapper.IMapper mapper) : Endpoint<GetQuotationRequest, GetQuotationDto>
{
public override void Configure()
{
Get("/quotations/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetQuotationRequest req, CancellationToken ct)
{
Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct);
if (quotation == null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetQuotationDto>(quotation), ct);
}
}

View File

@@ -0,0 +1,38 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Quotation.Request;
using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Quotations;
namespace PyroFetes.Endpoints.Quotations;
public class PatchQuotationConditionsSaleEndpoint(
QuotationsRepository quotationsRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchQuotationConditionsSaleDto, GetQuotationDto>
{
public override void Configure()
{
Patch("/quotations/{@Id}/saleConditions", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(PatchQuotationConditionsSaleDto req, CancellationToken ct)
{
Quotation? quotation = await quotationsRepository.FirstOrDefaultAsync(new GetQuotationByIdSpec(req.Id), ct);
if (quotation == null)
{
await Send.NotFoundAsync(ct);
return;
}
quotation.ConditionsSale = req.ConditionsSale;
await quotationsRepository.UpdateAsync(quotation, ct);
await Send.OkAsync(mapper.Map<GetQuotationDto>(quotation), ct);
}
}

View File

@@ -0,0 +1,31 @@
using FastEndpoints;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Settings;
public class CreateSettingEndpoint(
SettingsRepository settingsRepository,
AutoMapper.IMapper mapper) : Endpoint<CreateSettingDto, GetSettingDto>
{
public override void Configure()
{
Post("/settings");
AllowAnonymous();
}
public override async Task HandleAsync(CreateSettingDto req, CancellationToken ct)
{
Setting setting = new Setting()
{
ElectronicSignature = req.ElectronicSignature,
Logo = req.Logo
};
await settingsRepository.AddAsync(setting, ct);
await Send.OkAsync(mapper.Map<GetSettingDto>(setting), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Settings;
namespace PyroFetes.Endpoints.Settings;
public class DeleteSettingRequest
{
public int Id { get; set; }
}
public class DeleteSettingEndpoint(SettingsRepository settingsRepository) : Endpoint<DeleteSettingRequest>
{
public override void Configure()
{
Delete("/settings/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(DeleteSettingRequest req, CancellationToken ct)
{
Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct);
if (setting == null)
{
await Send.NotFoundAsync(ct);
return;
}
await settingsRepository.DeleteAsync(setting, ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Settings;
namespace PyroFetes.Endpoints.Settings;
public class GetSettingRequest
{
public int Id { get; set; }
}
public class GetSettingEndpoint(
SettingsRepository settingsRepository,
AutoMapper.IMapper mapper) : Endpoint<GetSettingRequest, GetSettingDto>
{
public override void Configure()
{
Get("/settings/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetSettingRequest req, CancellationToken ct)
{
Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct);
if (setting == null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetSettingDto>(setting), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Settings;
namespace PyroFetes.Endpoints.Settings;
public class PatchSettingElectronicSignatureEndpoint(
SettingsRepository settingsRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchSettingElectronicSignatureDto, GetSettingDto>
{
public override void Configure()
{
Patch("/settings/{@Id}/ElectronicSignature", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(PatchSettingElectronicSignatureDto req, CancellationToken ct)
{
Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct);
if (setting == null)
{
await Send.NotFoundAsync(ct);
return;
}
setting.ElectronicSignature = req.ElectronicSignature;
await settingsRepository.UpdateAsync(setting, ct);
await Send.OkAsync(mapper.Map<GetSettingDto>(setting), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Settings;
namespace PyroFetes.Endpoints.Settings;
public class PatchSettingLogoEndpoint(
SettingsRepository settingsRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchSettingLogoDto, GetSettingDto>
{
public override void Configure()
{
Patch("/settings/{@Id}/logo", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(PatchSettingLogoDto req, CancellationToken ct)
{
Setting? setting = await settingsRepository.FirstOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct);
if (setting == null)
{
await Send.NotFoundAsync(ct);
return;
}
setting.Logo = req.Logo;
await settingsRepository.UpdateAsync(setting, ct);
await Send.OkAsync(mapper.Map<GetSettingDto>(setting), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using PyroFetes.DTO.Supplier.Request;
using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Suppliers;
public class CreateSupplierEndpoint(
SuppliersRepository suppliersRepository,
AutoMapper.IMapper mapper) : Endpoint<CreateSupplierDto, GetSupplierDto>
{
public override void Configure()
{
Post("/suppliers");
AllowAnonymous();
}
public override async Task HandleAsync(CreateSupplierDto req, CancellationToken ct)
{
Supplier? supplier = new Supplier()
{
Name = req.Name,
Email = req.Email,
Phone = req.Phone,
Address = req.Address,
City = req.City,
ZipCode = req.ZipCode,
DeliveryDelay = req.DeliveryDelay
};
await suppliersRepository.AddAsync(supplier, ct);
await Send.OkAsync(mapper.Map<GetSupplierDto>(supplier), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Suppliers;
namespace PyroFetes.Endpoints.Suppliers;
public class DeleteSupplierRequest
{
public int Id { get; set; }
}
public class DeleteSupplierEndpoint(SuppliersRepository suppliersRepository) : Endpoint<DeleteSupplierRequest>
{
public override void Configure()
{
Delete("/suppliers/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(DeleteSupplierRequest req, CancellationToken ct)
{
Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct);
if (supplier == null)
{
await Send.NotFoundAsync(ct);
return;
}
await suppliersRepository.DeleteAsync(supplier, ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,20 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Suppliers;
public class GetAllSuppliersEndpoint(SuppliersRepository suppliersRepository) : EndpointWithoutRequest<List<GetSupplierDto>>
{
public override void Configure()
{
Get("/suppliers");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await suppliersRepository.ProjectToListAsync<GetSupplierDto>(ct), ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Suppliers;
namespace PyroFetes.Endpoints.Suppliers;
public class GetSupplierRequest
{
public int Id { get; set; }
}
public class GetSupplierEndpoint(
SuppliersRepository suppliersRepository,
AutoMapper.IMapper mapper) : Endpoint<GetSupplierRequest, GetSupplierDto>
{
public override void Configure()
{
Get("/suppliers/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetSupplierRequest req, CancellationToken ct)
{
Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct);
if (supplier == null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetSupplierDto>(supplier), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Supplier.Request;
using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Suppliers;
namespace PyroFetes.Endpoints.Suppliers;
public class PatchSupplierDeliveryDelayEndpoint(
SuppliersRepository suppliersRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchSupplierDeliveryDelayDto, GetSupplierDto>
{
public override void Configure()
{
Patch("/suppliers/{@Id}/deliveryDelay", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(PatchSupplierDeliveryDelayDto req, CancellationToken ct)
{
Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct);
if (supplier == null)
{
await Send.NotFoundAsync(ct);
return;
}
supplier.DeliveryDelay = req.DeliveryDelay;
await suppliersRepository.UpdateAsync(supplier, ct);
await Send.OkAsync(mapper.Map<GetSupplierDto>(supplier), ct);
}
}

View File

@@ -0,0 +1,43 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Supplier.Request;
using PyroFetes.DTO.Supplier.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Suppliers;
namespace PyroFetes.Endpoints.Suppliers;
public class UpdateSupplierEndpoint(
SuppliersRepository suppliersRepository,
AutoMapper.IMapper mapper) : Endpoint<UpdateSupplierDto, GetSupplierDto>
{
public override void Configure()
{
Put("/suppliers/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(UpdateSupplierDto req, CancellationToken ct)
{
Supplier? supplier = await suppliersRepository.FirstOrDefaultAsync(new GetSupplierByIdSpec(req.Id), ct);
if (supplier == null)
{
await Send.NotFoundAsync(ct);
return;
}
supplier.Name = req.Name;
supplier.Email = req.Email;
supplier.Phone = req.Phone;
supplier.Address = req.Address;
supplier.City = req.City;
supplier.ZipCode = req.ZipCode;
supplier.DeliveryDelay = req.DeliveryDelay;
await suppliersRepository.UpdateAsync(supplier, ct);
await Send.OkAsync(mapper.Map<GetSupplierDto>(supplier), ct);
}
}

View File

@@ -0,0 +1,51 @@
using FastEndpoints;
using FastEndpoints.Security;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Users;
namespace PyroFetes.Endpoints.Users;
public class ConnectUserEndpoint(UsersRepository usersRepository) : Endpoint<ConnectUserDto, GetTokenDto>
{
public override void Configure()
{
Post("/users/connection");
AllowAnonymous();
}
public override async Task HandleAsync(ConnectUserDto req, CancellationToken ct)
{
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct);
if (user == null)
{
await Send.UnauthorizedAsync(ct);
return;
}
if (BCrypt.Net.BCrypt.Verify(req.Password + user.Salt, user.Password))
{
string jwtToken = JwtBearer.CreateToken(
o =>
{
o.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong";
o.ExpireAt = DateTime.UtcNow.AddMinutes(15);
if (user.Fonction != null) o.User.Roles.Add(user.Fonction);
o.User.Claims.Add(("Name", user.Name)!);
o.User.Claims.Add(("Id", user.Id.ToString())!);
});
GetTokenDto responseDto = new()
{
Token = jwtToken
};
await Send.OkAsync(responseDto, ct);
}
else await Send.UnauthorizedAsync(ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using PasswordGenerator;
using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Users;
public class CreateUserEndpoint(
UsersRepository usersRepository,
AutoMapper.IMapper mapper) : Endpoint<CreateUserDto, GetUserDto>
{
public override void Configure()
{
Post("/users");
AllowAnonymous();
}
public override async Task HandleAsync(CreateUserDto req, CancellationToken ct)
{
string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next();
User user = new User()
{
Name = req.Name,
Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt),
Salt = salt,
Email = req.Email,
Fonction = req.Fonction
};
await usersRepository.AddAsync(user, ct);
await Send.OkAsync(mapper.Map<GetUserDto>(user), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Users;
namespace PyroFetes.Endpoints.Users;
public class DeleteUserRequest
{
public int Id { get; set; }
}
public class DeleteUserEndpoint(UsersRepository usersRepository) : Endpoint<DeleteUserRequest>
{
public override void Configure()
{
Delete("/users/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(DeleteUserRequest req, CancellationToken ct)
{
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct);
if (user == null)
{
await Send.NotFoundAsync(ct);
return;
}
await usersRepository.DeleteAsync(user, ct);
await Send.NoContentAsync(ct);
}
}

View File

@@ -0,0 +1,20 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Response;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Users;
public class GetAllUsersEndpoint(UsersRepository usersRepository) : EndpointWithoutRequest<List<GetUserDto>>
{
public override void Configure()
{
Get("/users");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await usersRepository.ProjectToListAsync<GetUserDto>(ct), ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Users;
namespace PyroFetes.Endpoints.Users;
public class GetUserRequest
{
public int Id { get; set; }
}
public class GetUserEndpoint(
UsersRepository usersRepository,
AutoMapper.IMapper mapper) : Endpoint<GetUserRequest, GetUserDto>
{
public override void Configure()
{
Get("/users/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetUserRequest req, CancellationToken ct)
{
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct);
if (user == null)
{
await Send.NotFoundAsync(ct);
return;
}
await Send.OkAsync(mapper.Map<GetUserDto>(user), ct);
}
}

View File

@@ -0,0 +1,36 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Users;
namespace PyroFetes.Endpoints.Users;
public class PatchUserPasswordEndpoint(
UsersRepository usersRepository,
AutoMapper.IMapper mapper) : Endpoint<PatchUserPasswordDto, GetUserDto>
{
public override void Configure()
{
Patch("/users/{@Id}/password", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(PatchUserPasswordDto req, CancellationToken ct)
{
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct);
if (user == null)
{
await Send.NotFoundAsync(ct);
return;
}
user.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + user.Salt);
await usersRepository.UpdateAsync(user, ct);
await Send.OkAsync(mapper.Map<GetUserDto>(user), ct);
}
}

View File

@@ -0,0 +1,51 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PasswordGenerator;
using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.User.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Users;
namespace PyroFetes.Endpoints.Users;
public class UpdateUserEndpoint(
UsersRepository usersRepository,
AutoMapper.IMapper mapper) : Endpoint<UpdateUserDto, GetUserDto>
{
public override void Configure()
{
Put("/users/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(UpdateUserDto req, CancellationToken ct)
{
User? user = await usersRepository.FirstOrDefaultAsync(new GetUserByIdSpec(req.Id), ct);
User? ckeckName = await usersRepository.FirstOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct);
if (user == null)
{
await Send.NotFoundAsync(ct);
return;
}
if (ckeckName != null)
{
await Send.StringAsync("Ce nom d'utilisateur existe déjà.",409, cancellation: ct);
return;
}
string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next();
user.Name = req.Name;
user.Password = BCrypt.Net.BCrypt.HashPassword(req.Password + salt);
user.Salt = salt;
user.Email = req.Email;
user.Fonction = req.Fonction;
await usersRepository.UpdateAsync(user, ct);
await Send.OkAsync(mapper.Map<GetUserDto>(user), ct);
}
}

View File

@@ -0,0 +1,45 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.WareHouseProduct.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.WarehouseProducts;
namespace PyroFetes.Endpoints.WareHouseProducts;
public class GetTotalQuantityRequest
{
public int ProductId { get; set; }
}
public class GetTotalQuantityEndpoint(
WarehouseProductsRepository warehouseProductsRepository) : Endpoint<GetTotalQuantityRequest, GetTotalQuantityDto>
{
public override void Configure()
{
Get("/wareHouseProducts/{@ProductId}", x => new { x.ProductId });
AllowAnonymous();
}
public override async Task HandleAsync(GetTotalQuantityRequest req, CancellationToken ct)
{
bool exists = await warehouseProductsRepository.AnyAsync(new GetWarehouseProductByProductIdSpec(req.ProductId), ct);
if (!exists)
{
await Send.NotFoundAsync(ct);
return;
}
int totalQuantity =
await warehouseProductsRepository.SumAsync(new GetProductTotalQuantitySpec(req.ProductId),
wp => wp.Quantity, ct);
GetTotalQuantityDto responseDto = new()
{
ProductId = req.ProductId,
TotalQuantity = totalQuantity
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,41 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.WareHouseProduct.Request;
using PyroFetes.DTO.WareHouseProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.Endpoints.WareHouseProducts;
public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database)
: Endpoint<PatchWareHouseProductQuantityDto, GetWareHouseProductDto>
{
public override void Configure()
{
Patch("/wareHouseProducts/{@ProductId}/{@WareHouseId}/quantity", x => new { x.ProductId, x.WareHouseId });
AllowAnonymous();
}
public override async Task HandleAsync(PatchWareHouseProductQuantityDto req, CancellationToken ct)
{
WarehouseProduct? wareHouseProduct =
await database.WarehouseProducts.SingleOrDefaultAsync(
wp => wp.ProductId == req.ProductId && wp.WarehouseId == req.WareHouseId, ct);
if (wareHouseProduct == null)
{
await Send.NotFoundAsync(ct);
return;
}
wareHouseProduct.Quantity = req.Quantity;
await database.SaveChangesAsync(ct);
GetWareHouseProductDto responseDto = new()
{
ProductId = wareHouseProduct.ProductId,
WareHouseId = wareHouseProduct.WarehouseId,
Quantity = wareHouseProduct.Quantity
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,68 @@
using AutoMapper;
using PyroFetes.DTO.Deliverer.Request;
using PyroFetes.DTO.DeliveryNote.Request;
using PyroFetes.DTO.Price.Request;
using PyroFetes.DTO.Product.Request;
using PyroFetes.DTO.ProductDelivery.Request;
using PyroFetes.DTO.PurchaseOrder.Request;
using PyroFetes.DTO.PurchaseProduct.Request;
using PyroFetes.DTO.Quotation.Request;
using PyroFetes.DTO.QuotationProduct.Request;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.Supplier.Request;
using PyroFetes.DTO.User.Request;
using PyroFetes.DTO.WareHouseProduct.Request;
using PyroFetes.Models;
namespace PyroFetes.MappingProfiles;
public class DtoToEntityMappings : Profile
{
public DtoToEntityMappings()
{
CreateMap<CreateDelivererDto, Deliverer>();
CreateMap<UpdateDelivererDto, Deliverer>();
CreateMap<CreateDeliveryNoteDto, DeliveryNote>();
CreateMap<UpdateDeliveryNoteDto, DeliveryNote>();
CreateMap<PatchDeliveryNoteRealDeliveryDateDto, DeliveryNote>();
CreateMap<CreatePriceDto, Price>();
CreateMap<UpdatePriceDto, Price>();
CreateMap<PatchPriceSellingPriceDto, Price>();
CreateMap<CreateProductDto, Product>();
CreateMap<UpdateProductDto, Product>();
CreateMap<PatchProductMinimalStockDto, Product>();
CreateMap<CreateProductDeliveryDto, ProductDelivery>();
CreateMap<UpdateProductDeliveryDto, ProductDelivery>();
CreateMap<PatchPurchaseOrderPurchaseConditionsDto,PurchaseOrder>();
CreateMap<CreatePurchaseProductDto, PurchaseProduct>();
CreateMap<UpdatePurchaseProductDto, PurchaseProduct>();
CreateMap<PatchPurchaseProductQuantityDto, PurchaseProduct>();
CreateMap<PatchQuotationConditionsSaleDto, Quotation>();
CreateMap<PatchQuotationMessageDto, Quotation>();
CreateMap<CreateQuotationProductDto, QuotationProduct>();
CreateMap<UpdateQuotationProductDto, QuotationProduct>();
CreateMap<PatchQuotationProductQuantityDto, QuotationProduct>();
CreateMap<CreateSettingDto, Setting>();
CreateMap<PatchSettingElectronicSignatureDto, Setting>();
CreateMap<PatchSettingLogoDto, Setting>();
CreateMap<CreateSupplierDto, Supplier>();
CreateMap<UpdateSupplierDto, Supplier>();
CreateMap<PatchSupplierDeliveryDelayDto, Supplier>();
CreateMap<CreateUserDto, User>();
CreateMap<UpdateUserDto, User>();
CreateMap<PatchUserPasswordDto, User>();
CreateMap<PatchWareHouseProductQuantityDto, WarehouseProduct>();
}
}

View File

@@ -0,0 +1,46 @@
using AutoMapper;
using PyroFetes.DTO.Deliverer.Response;
using PyroFetes.DTO.DeliveryNote.Response;
using PyroFetes.DTO.Price.Response;
using PyroFetes.DTO.Product.Response;
using PyroFetes.DTO.ProductDelivery.Response;
using PyroFetes.DTO.PurchaseOrder.Response;
using PyroFetes.DTO.PurchaseProduct.Response;
using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Response;
using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.DTO.User.Response;
using PyroFetes.DTO.WareHouseProduct.Response;
using PyroFetes.Models;
namespace PyroFetes.MappingProfiles;
public class EntityToDtoMappings : Profile
{
public EntityToDtoMappings()
{
CreateMap<Deliverer, GetDelivererDto>();
CreateMap<DeliveryNote, GetDeliveryNoteDto>();
CreateMap<Price, GetPriceDto>();
CreateMap<Product, GetProductDto>();
CreateMap<ProductDelivery, GetProductDeliveryDto>();
CreateMap<PurchaseOrder, GetPurchaseOrderDto>();
CreateMap<PurchaseProduct, GetPurchaseProductDto>();
CreateMap<Quotation, GetQuotationDto>();
CreateMap<QuotationProduct, GetQuotationProductDto>();
CreateMap<Setting, GetSettingDto>();
CreateMap<User, GetUserDto>();
CreateMap<WarehouseProduct, GetWareHouseProductDto>();
}
}

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