forked from sanchezvem/PyroFetes
MaJ des .txt en .cs
This commit is contained in:
@@ -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()
|
@@ -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);
|
||||
}
|
@@ -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,
|
@@ -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);
|
||||
|
@@ -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()
|
||||
{
|
Reference in New Issue
Block a user