MaJ des .txt en .cs

This commit is contained in:
2025-10-09 16:09:30 +02:00
parent 44da6ed371
commit c5805d979b
15 changed files with 65 additions and 70 deletions

View File

@@ -2,9 +2,9 @@ using API.DTO.Color.Request;
using API.DTO.Color.Response;
using FastEndpoints;
namespace API.Endpoints.Color;
namespace PyroFetes.Endpoints.Color;
public class CreateColorEndpoint(AppDbContext appDbContext) : Endpoint<CreateColorDto, GetColorDto>
public class CreateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateColorDto, GetColorDto>
{
public override void Configure()
{
@@ -19,8 +19,8 @@ public class CreateColorEndpoint(AppDbContext appDbContext) : Endpoint<CreateCol
Label = req.Label,
};
appDbContext.Colors.Add(color);
await appDbContext.SaveChangesAsync(ct);
pyrofetesdbcontext.Colors.Add(color);
await pyrofetesdbcontext.SaveChangesAsync(ct);
Console.WriteLine("Added Color");
GetColorDto responseDto = new()

View File

@@ -1,14 +1,14 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Color;
namespace PyroFetes.Endpoints.Color;
public class DeleteColorRequest
{
public int Id { get; set; }
}
public class DeleteColorEndpoint(AppDbContext appDbContext) : Endpoint<DeleteColorRequest>
public class DeleteColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteColorRequest>
{
public override void Configure()
{
@@ -18,7 +18,7 @@ public class DeleteColorEndpoint(AppDbContext appDbContext) : Endpoint<DeleteCol
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct)
{
Models.Color? colorToDelete = await appDbContext
Models.Color? colorToDelete = await pyrofetesdbcontext
.Colors
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
@@ -29,8 +29,8 @@ public class DeleteColorEndpoint(AppDbContext appDbContext) : Endpoint<DeleteCol
return;
}
appDbContext.Colors.Remove(colorToDelete);
await appDbContext.SaveChangesAsync(ct);
pyrofetesdbcontext.Colors.Remove(colorToDelete);
await pyrofetesdbcontext.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}

View File

@@ -2,9 +2,9 @@ using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Color;
namespace PyroFetes.Endpoints.Color;
public class GetAllColorsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetColorDto>>
public class GetAllColorsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetColorDto>>
{
public override void Configure()
{
@@ -14,7 +14,7 @@ public class GetAllColorsEndpoint(AppDbContext appDbContext) : EndpointWithoutRe
public override async Task HandleAsync(CancellationToken ct)
{
List<GetColorDto> responseDto = await appDbContext.Colors
List<GetColorDto> responseDto = await pyrofetesdbcontext.Colors
.Select(a => new GetColorDto
{
Id = a.Id,

View File

@@ -1,16 +1,15 @@
using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Color;
namespace PyroFetes.Endpoints.Color;
public class GetColorRequest
{
public int Id { get; set; }
}
public class GetColorEndpoint(AppDbContext appDbContext) : Endpoint<GetColorRequest, GetColorDto>
public class GetColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetColorRequest, GetColorDto>
{
public override void Configure()
{
@@ -20,7 +19,7 @@ public class GetColorEndpoint(AppDbContext appDbContext) : Endpoint<GetColorRequ
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct)
{
Models.Color? color = await appDbContext
Models.Color? color = await pyrofetesdbcontext
.Colors
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);

View File

@@ -1,12 +1,11 @@
using API.DTO.Color.Request;
using API.DTO.Color.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Color;
namespace PyroFetes.Endpoints.Color;
public class UpdateColorEndpoint(AppDbContext appDbContext) : Endpoint<UpdateColorDto, GetColorDto>
public class UpdateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateColorDto, GetColorDto>
{
public override void Configure()
{
@@ -16,7 +15,7 @@ public class UpdateColorEndpoint(AppDbContext appDbContext) : Endpoint<UpdateCol
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
{
Models.Color? colorToEdit = await appDbContext
Models.Color? colorToEdit = await pyrofetesdbcontext
.Colors
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
@@ -28,7 +27,7 @@ public class UpdateColorEndpoint(AppDbContext appDbContext) : Endpoint<UpdateCol
}
colorToEdit.Label = req.Label;
await appDbContext.SaveChangesAsync(ct);
await pyrofetesdbcontext.SaveChangesAsync(ct);
GetColorDto responseDto = new()
{

View File

@@ -1,10 +1,10 @@
using API.DTO.Effect.Request;
using API.DTO.Effect.Response;
using FastEndpoints;
namespace API.Endpoints.Effect;
public class CreateEffectEndpoint(AppDbContext appDbContext) : Endpoint<CreateEffectDto, GetEffectDto>
namespace PyroFetes.Endpoints.Effect;
public class CreateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateEffectDto, GetEffectDto>
{
public override void Configure()
{
@@ -19,8 +19,8 @@ public class CreateEffectEndpoint(AppDbContext appDbContext) : Endpoint<CreateEf
Label = req.Label,
};
appDbContext.Effects.Add(effect);
await appDbContext.SaveChangesAsync(ct);
pyrofetesdbcontext.Effects.Add(effect);
await pyrofetesdbcontext.SaveChangesAsync(ct);
Console.WriteLine("Effect added");
GetEffectDto responseDto = new()

View File

@@ -1,13 +1,13 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Effect;
namespace PyroFetes.Endpoints.Effect;
public class DeleteEffectRequest
{
public int Id { get; set; }
}
public class DeleteEffectEndpoint(AppDbContext appDbContext) : Endpoint<DeleteEffectRequest>
public class DeleteEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteEffectRequest>
{
public override void Configure()
{
@@ -17,7 +17,7 @@ public class DeleteEffectEndpoint(AppDbContext appDbContext) : Endpoint<DeleteEf
public override async Task HandleAsync(DeleteEffectRequest req, CancellationToken ct)
{
Models.Effect? effectToDelete = await appDbContext
Models.Effect? effectToDelete = await pyrofetesdbcontext
.Effects
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
@@ -28,8 +28,8 @@ public class DeleteEffectEndpoint(AppDbContext appDbContext) : Endpoint<DeleteEf
return;
}
appDbContext.Effects.Remove(effectToDelete);
await appDbContext.SaveChangesAsync(ct);
pyrofetesdbcontext.Effects.Remove(effectToDelete);
await pyrofetesdbcontext.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}

View File

@@ -2,9 +2,9 @@ using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Effect;
namespace PyroFetes.Endpoints.Effect;
public class GetAllEffectsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetEffectDto>>
public class GetAllEffectsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetEffectDto>>
{
public override void Configure()
{
@@ -14,7 +14,7 @@ public class GetAllEffectsEndpoint(AppDbContext appDbContext) : EndpointWithoutR
public override async Task HandleAsync(CancellationToken ct)
{
List<GetEffectDto> responseDto = await appDbContext.Effects
List<GetEffectDto> responseDto = await pyrofetesdbcontext.Effects
.Select(a => new GetEffectDto
{
Id = a.Id,

View File

@@ -1,16 +1,15 @@
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Effect;
namespace PyroFetes.Endpoints.Effect;
public class GetEffectRequest
{
public int Id { get; set; }
}
public class GetEffectEndpoint(AppDbContext appDbContext) : Endpoint<GetEffectRequest, GetEffectDto>
public class GetEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetEffectRequest, GetEffectDto>
{
public override void Configure()
{
@@ -20,7 +19,7 @@ public class GetEffectEndpoint(AppDbContext appDbContext) : Endpoint<GetEffectRe
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct)
{
Models.Effect? effect = await appDbContext
Models.Effect? effect = await pyrofetesdbcontext
.Effects
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);

View File

@@ -1,12 +1,11 @@
using API.DTO.Effect.Request;
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Effect;
namespace PyroFetes.Endpoints.Effect;
public class UpdateEffectEndpoint(AppDbContext appDbContext) : Endpoint<UpdateEffectDto, GetEffectDto>
public class UpdateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateEffectDto, GetEffectDto>
{
public override void Configure()
{
@@ -16,7 +15,7 @@ public class UpdateEffectEndpoint(AppDbContext appDbContext) : Endpoint<UpdateEf
public override async Task HandleAsync(UpdateEffectDto req, CancellationToken ct)
{
Models.Effect? effectToEdit = await appDbContext
Models.Effect? effectToEdit = await pyrofetesdbcontext
.Effects
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
@@ -28,7 +27,7 @@ public class UpdateEffectEndpoint(AppDbContext appDbContext) : Endpoint<UpdateEf
}
effectToEdit.Label = req.Label;
await appDbContext.SaveChangesAsync(ct);
await pyrofetesdbcontext.SaveChangesAsync(ct);
GetEffectDto responseDto = new()
{

View File

@@ -1,9 +1,10 @@
using API.DTO.Material.Request;
using API.DTO.Material.Response;
using FastEndpoints;
namespace API.Endpoints.Material;
public class CreateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<CreateMaterialDto, GetMaterialDto>
namespace PyroFetes.Endpoints.Material;
public class CreateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<CreateMaterialDto, GetMaterialDto>
{
public override void Configure()
{
@@ -15,20 +16,20 @@ public class CreateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Create
{
Models.Material quantity = new()
{
Name = req.Name,
Name = req.Label,
Quantity = req.Quantity,
WarehouseId = req.WarehouseId,
};
appDbContext.Materials.Add(quantity);
await appDbContext.SaveChangesAsync(ct);
pyrofetesdbcontext.Materials.Add(quantity);
await pyrofetesdbcontext.SaveChangesAsync(ct);
Console.WriteLine("Material added");
GetMaterialDto responseDto = new()
{
Id = quantity.Id,
WarehouseId = quantity.WarehouseId,
Name = req.Name,
Label = req.Label,
};
await Send.OkAsync(responseDto, ct);

View File

@@ -1,12 +1,12 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
namespace PyroFetes.Endpoints.Material;
public class DeleteMaterialRequest
{
public int Id { get; set; }
}
public class DeleteMaterialEndpoint(AppDbContext appDbContext) : Endpoint<DeleteMaterialRequest>
public class DeleteMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<DeleteMaterialRequest>
{
public override void Configure()
{
@@ -16,7 +16,7 @@ public class DeleteMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Delete
public override async Task HandleAsync(DeleteMaterialRequest req, CancellationToken ct)
{
Models.Material? materialToDelete = await appDbContext
Models.Material? materialToDelete = await pyrofetesdbcontext
.Materials
.SingleOrDefaultAsync(a => a.Id == req.Id, cancellationToken: ct);
@@ -27,8 +27,8 @@ public class DeleteMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Delete
return;
}
appDbContext.Materials.Remove(materialToDelete);
await appDbContext.SaveChangesAsync(ct);
pyrofetesdbcontext.Materials.Remove(materialToDelete);
await pyrofetesdbcontext.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}

View File

@@ -2,9 +2,9 @@ using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
namespace PyroFetes.Endpoints.Material;
public class GetAllMaterialsEndpoint(AppDbContext appDbContext) : EndpointWithoutRequest<List<GetMaterialDto>>
public class GetAllMaterialsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMaterialDto>>
{
public override void Configure()
{
@@ -14,11 +14,11 @@ public class GetAllMaterialsEndpoint(AppDbContext appDbContext) : EndpointWithou
public override async Task HandleAsync(CancellationToken ct)
{
List<GetMaterialDto> responseDto = await appDbContext.Materials
List<GetMaterialDto> responseDto = await pyrofetesdbcontext.Materials
.Select(a => new GetMaterialDto
{
Id = a.Id,
Name = a.Name,
Label = a.Name,
Quantity = a.Quantity,
WarehouseId = a.WarehouseId,
}

View File

@@ -1,16 +1,15 @@
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
namespace PyroFetes.Endpoints.Material;
public class GetMaterialRequest
{
public int Id { get; set; }
}
public class GetMaterialEndpoint(AppDbContext appDbContext) : Endpoint<GetMaterialRequest, GetMaterialDto>
public class GetMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetMaterialRequest, GetMaterialDto>
{
public override void Configure()
{
@@ -20,7 +19,7 @@ public class GetMaterialEndpoint(AppDbContext appDbContext) : Endpoint<GetMateri
public override async Task HandleAsync(GetMaterialRequest req, CancellationToken ct)
{
Models.Material? material = await appDbContext
Models.Material? material = await pyrofetesdbcontext
.Materials
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
@@ -34,7 +33,7 @@ public class GetMaterialEndpoint(AppDbContext appDbContext) : Endpoint<GetMateri
GetMaterialDto responseDto = new()
{
Id = material.Id,
Name = material.Name,
Label = material.Name,
WarehouseId = material.WarehouseId,
};
await Send.OkAsync(responseDto, ct);

View File

@@ -1,12 +1,11 @@
using API.DTO.Material.Request;
using API.DTO.Material.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.EntityFrameworkCore;
namespace API.Endpoints.Material;
namespace PyroFetes.Endpoints.Material;
public class UpdateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<UpdateMaterialDto, GetMaterialDto>
public class UpdateMaterialEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateMaterialDto, GetMaterialDto>
{
public override void Configure()
{
@@ -16,7 +15,7 @@ public class UpdateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Update
public override async Task HandleAsync(UpdateMaterialDto req, CancellationToken ct)
{
Models.Material? materialToEdit = await appDbContext
Models.Material? materialToEdit = await pyrofetesdbcontext
.Materials
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
@@ -27,14 +26,14 @@ public class UpdateMaterialEndpoint(AppDbContext appDbContext) : Endpoint<Update
return;
}
materialToEdit.Name = req.Name;
materialToEdit.Name = req.Label;
materialToEdit.WarehouseId = req.WarehouseId;
await appDbContext.SaveChangesAsync(ct);
await pyrofetesdbcontext.SaveChangesAsync(ct);
GetMaterialDto responseDto = new()
{
Id = req.Id,
Name = req.Name,
Label = req.Label,
WarehouseId = req.WarehouseId,
};
await Send.OkAsync(responseDto, ct);