Modifs de noms et providers

This commit is contained in:
2026-06-07 19:06:45 +02:00
parent 7da7c26a2e
commit af21591669
15 changed files with 60 additions and 16 deletions
@@ -1,4 +1,5 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.Provider.Request;
using PyroFetes.DTO.Provider.Response;
@@ -8,16 +9,26 @@ public class CreateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End
{
public override void Configure()
{
Post("/providers");
Post("/serviceproviders");
AllowAnonymous();
}
public override async Task HandleAsync(CreateProviderDto req, CancellationToken ct)
{
var provider = new Models.ServiceProvider()
Models.ProviderType? databaseProviderType = await pyroFetesDbContext.ProviderTypes.SingleOrDefaultAsync(x => x.Id == req.ProviderTypeId, cancellationToken: ct);
if (databaseProviderType == null)
{
Price = req.Price
await Send.NotFoundAsync(ct);
Console.WriteLine("Customer Type not found");
return;
}
Models.ServiceProvider provider = new()
{
Price = req.Price,
ProviderTypeId = req.ProviderTypeId
};
pyroFetesDbContext.Add(provider);
await pyroFetesDbContext.SaveChangesAsync(ct);
@@ -25,7 +36,8 @@ public class CreateProviderEndpoint(PyroFetesDbContext pyroFetesDbContext) : End
GetProviderDto response = new GetProviderDto()
{
Id = provider.Id,
Price = provider.Price
Price = provider.Price,
ProviderTypeId = provider.ProviderTypeId
};
await Send.OkAsync(response, ct);