fix error in api's route
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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">
|
||||
|
Reference in New Issue
Block a user