From aa1c98d649fe5cd26d10a08f045e5aabd4d229b4 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Fri, 17 Oct 2025 16:47:34 +0100 Subject: [PATCH] fix error in api's route --- .../DeletePurchaseOrderEndpoint.cs | 2 +- ...PurchaseOrderPurchaseConditionsEndpoint.cs | 2 +- .../DeletePurchaseProductEndpoint.cs | 2 +- .../PatchPurchaseProductQuantityEndpoint.cs | 2 +- .../Quotation/DeleteQuotationEndpoint.cs | 2 +- .../PatchQuotationConditionsSaleEndpoint.cs | 2 +- .../DeleteQuotationProductEndpoint.cs | 2 +- .../PatchQuotationProductQuantityEndpoint.cs | 2 +- .../GetTotalQuantityEndpoint.cs | 4 +-- .../PatchWareHouseProductQuantityEndpoint.cs | 2 +- PyroFetes/Program.cs | 32 ++++++++++++------- PyroFetes/PyroFetes.csproj | 2 ++ 12 files changed, 33 insertions(+), 23 deletions(-) diff --git a/PyroFetes/Endpoints/PurchaseOrder/DeletePurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrder/DeletePurchaseOrderEndpoint.cs index 50bce61..a6a990a 100644 --- a/PyroFetes/Endpoints/PurchaseOrder/DeletePurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrder/DeletePurchaseOrderEndpoint.cs @@ -12,7 +12,7 @@ public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint { public override void Configure() { - Delete("/api/purchaseOrders/{Id}", x => new {x.Id}); + Delete("/api/purchaseOrders/{@Id}", x => new {x.Id}); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/PurchaseOrder/PatchPurchaseOrderPurchaseConditionsEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrder/PatchPurchaseOrderPurchaseConditionsEndpoint.cs index ee6bbff..a6bbff0 100644 --- a/PyroFetes/Endpoints/PurchaseOrder/PatchPurchaseOrderPurchaseConditionsEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrder/PatchPurchaseOrderPurchaseConditionsEndpoint.cs @@ -11,7 +11,7 @@ public class PatchPurchaseOrderPurchaseConditionsEndpoint(PyroFetesDbContext dat { public override void Configure() { - Patch("/api/purchaseOrders/{Id}/PurchaseConditions", x => new { x.Id }); + Patch("/api/purchaseOrders/{@Id}/PurchaseConditions", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs b/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs index 02853da..93d60fb 100644 --- a/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseProduct/DeletePurchaseProductEndpoint.cs @@ -13,7 +13,7 @@ public class DeletePurchaseOrderEndpoint(PyroFetesDbContext database) : Endpoint { public override void Configure() { - Delete("/api/purchaseProducts/{ProductId}/{PurchaseOrderId}", x => new {x.ProductId, x.PurchaseOrderId}); + Delete("/api/purchaseProducts/{@ProductId}/{@PurchaseOrderId}", x => new {x.ProductId, x.PurchaseOrderId}); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs index 2253987..952dd8d 100644 --- a/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseProduct/PatchPurchaseProductQuantityEndpoint.cs @@ -9,7 +9,7 @@ public class PatchPurchaseProductQuantityEndpoint(PyroFetesDbContext database) : { public override void Configure() { - Patch("/api/purchaseProducts/{ProductId}/{PurchaseOrderId}/Quantity", x => new { x.ProductId, x.PurchaseOrderId }); + Patch("/api/purchaseProducts/{@ProductId}/{@PurchaseOrderId}/Quantity", x => new { x.ProductId, x.PurchaseOrderId }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Quotation/DeleteQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotation/DeleteQuotationEndpoint.cs index 3077bc1..e83ae15 100644 --- a/PyroFetes/Endpoints/Quotation/DeleteQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotation/DeleteQuotationEndpoint.cs @@ -12,7 +12,7 @@ public class DeleteQuotationEndpoint(PyroFetesDbContext database) : Endpoint new {x.Id}); + Delete("/api/quotations/{@Id}", x => new {x.Id}); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/Quotation/PatchQuotationConditionsSaleEndpoint.cs b/PyroFetes/Endpoints/Quotation/PatchQuotationConditionsSaleEndpoint.cs index a7d520e..8cc9609 100644 --- a/PyroFetes/Endpoints/Quotation/PatchQuotationConditionsSaleEndpoint.cs +++ b/PyroFetes/Endpoints/Quotation/PatchQuotationConditionsSaleEndpoint.cs @@ -13,7 +13,7 @@ public class PatchQuotationConditionsSaleEndpoint(PyroFetesDbContext database) : { public override void Configure() { - Patch("/api/quotations/{Id}/ConditionsSale", x => new { x.Id }); + Patch("/api/quotations/{@Id}/ConditionsSale", x => new { x.Id }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/QuotationProduct/DeleteQuotationProductEndpoint.cs b/PyroFetes/Endpoints/QuotationProduct/DeleteQuotationProductEndpoint.cs index fa38341..aa480e8 100644 --- a/PyroFetes/Endpoints/QuotationProduct/DeleteQuotationProductEndpoint.cs +++ b/PyroFetes/Endpoints/QuotationProduct/DeleteQuotationProductEndpoint.cs @@ -13,7 +13,7 @@ public class DeleteQuotationProductEndpoint(PyroFetesDbContext database) : Endpo { public override void Configure() { - Delete("/api/quotationProduct/{ProductId}/{QuotationId}", x => new {x.ProductId, x.QuotationId}); + Delete("/api/quotationProduct/{@ProductId}/{@QuotationId}", x => new {x.ProductId, x.QuotationId}); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/QuotationProduct/PatchQuotationProductQuantityEndpoint.cs b/PyroFetes/Endpoints/QuotationProduct/PatchQuotationProductQuantityEndpoint.cs index d6b043a..33c050e 100644 --- a/PyroFetes/Endpoints/QuotationProduct/PatchQuotationProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/QuotationProduct/PatchQuotationProductQuantityEndpoint.cs @@ -9,7 +9,7 @@ public class PatchQuotationProductQuantityEndpoint(PyroFetesDbContext database) { public override void Configure() { - Patch("/api/quotationProduct/{ProductId}/{QuotationId}/Quantity", x => new { x.ProductId, x.QuotationId }); + Patch("/api/quotationProduct/{@ProductId}/{@QuotationId}/Quantity", x => new { x.ProductId, x.QuotationId }); AllowAnonymous(); } diff --git a/PyroFetes/Endpoints/WareHouseProduct/GetTotalQuantityEndpoint.cs b/PyroFetes/Endpoints/WareHouseProduct/GetTotalQuantityEndpoint.cs index c5921f0..0005391 100644 --- a/PyroFetes/Endpoints/WareHouseProduct/GetTotalQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/WareHouseProduct/GetTotalQuantityEndpoint.cs @@ -13,13 +13,13 @@ public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint new { x.ProductId }); + Get("/api/wareHouseProduct/{@ProductId}", x => new { x.ProductId }); AllowAnonymous(); } public override async Task HandleAsync(GetTotalQuantityRequest req, CancellationToken ct) { - bool exists = await database.WarehouseProducts + var exists = await database.WarehouseProducts .AnyAsync(wp => wp.ProductId == req.ProductId, ct); if (!exists) diff --git a/PyroFetes/Endpoints/WareHouseProduct/PatchWareHouseProductQuantityEndpoint.cs b/PyroFetes/Endpoints/WareHouseProduct/PatchWareHouseProductQuantityEndpoint.cs index fee191d..d5cc5f8 100644 --- a/PyroFetes/Endpoints/WareHouseProduct/PatchWareHouseProductQuantityEndpoint.cs +++ b/PyroFetes/Endpoints/WareHouseProduct/PatchWareHouseProductQuantityEndpoint.cs @@ -11,7 +11,7 @@ public class PatchWareHouseProductQuantityEndpoint(PyroFetesDbContext database) { public override void Configure() { - Patch("/api/wareHouseProduct/{ProductId}/{WareHouseId}/Quantity", x => new { x.ProductId, x.WareHouseId }); + Patch("/api/wareHouseProduct/{@ProductId}/{@WareHouseId}/Quantity", x => new { x.ProductId, x.WareHouseId }); AllowAnonymous(); } diff --git a/PyroFetes/Program.cs b/PyroFetes/Program.cs index d127d73..e92c405 100644 --- a/PyroFetes/Program.cs +++ b/PyroFetes/Program.cs @@ -1,18 +1,26 @@ -var builder = WebApplication.CreateBuilder(args); +using PyroFetes; +using FastEndpoints; +using FastEndpoints.Swagger; +using FastEndpoints.Security; -// 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 + .AddAuthenticationJwtBearer(s => s.SigningKey = "ThisIsASuperSecretJwtKeyThatIsAtLeast32CharsLong") + .AddAuthorization() + .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(); + +// On construit l'application en lui donnant vie +WebApplication app = builder.Build(); +app.UseAuthentication() + .UseAuthorization() + .UseFastEndpoints() + .UseSwaggerGen(); app.UseHttpsRedirection(); diff --git a/PyroFetes/PyroFetes.csproj b/PyroFetes/PyroFetes.csproj index 289fb53..ed5ce50 100644 --- a/PyroFetes/PyroFetes.csproj +++ b/PyroFetes/PyroFetes.csproj @@ -9,6 +9,8 @@ + +