fix error in api's route

This commit is contained in:
2025-10-17 16:47:34 +01:00
parent fa72c6d777
commit aa1c98d649
12 changed files with 33 additions and 23 deletions

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -12,7 +12,7 @@ public class DeleteQuotationEndpoint(PyroFetesDbContext database) : Endpoint<Del
{
public override void Configure()
{
Delete("/api/quotations/{Id}", x => new {x.Id});
Delete("/api/quotations/{@Id}", x => new {x.Id});
AllowAnonymous();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -13,13 +13,13 @@ public class GetTotalQuantityEndpoint(PyroFetesDbContext database) : Endpoint<Ge
{
public override void Configure()
{
Get("/api/wareHouseProduct/{ProductId}", x => 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)

View File

@@ -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();
}

View File

@@ -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<PyroFetesDbContext>();
// On construit l'application en lui donnant vie
WebApplication app = builder.Build();
app.UseAuthentication()
.UseAuthorization()
.UseFastEndpoints()
.UseSwaggerGen();
app.UseHttpsRedirection();

View File

@@ -9,6 +9,8 @@
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="FastEndpoints" Version="7.0.1" />
<PackageReference Include="FastEndpoints.Security" 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">