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()
{