fix all bug of Arsene's works

This commit is contained in:
2025-10-16 23:40:41 +01:00
parent 0121435594
commit cc09cb2156
7 changed files with 86 additions and 14 deletions

View File

@@ -1,9 +1,7 @@
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Setting;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
using FastEndpoints;
namespace PyroFetes.Endpoints.Setting;
public class CreateSettingEndpoint(PyroFetesDbContext database) : Endpoint<CreateSettingDto, GetSettingDto>
{

View File

@@ -1,15 +1,13 @@
namespace PyroFetes.Endpoint.Setting;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Setting;
public class DeleteSettingRequest
{
public int Id { get; set; }
}
public class DeleteSettingEndpoint(PyroFetesDbContext database) : Endpoint<DeleteSettingRequest>
{
public override void Configure()

View File

@@ -1,9 +1,10 @@
namespace PyroFetes.Endpoints.Setting;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Setting;
public class GetAllSettingEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetSettingDto>>
{
public override void Configure()

View File

@@ -1,8 +1,8 @@
namespace PyroFetes.Endpoint.Setting;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Response;
namespace PyroFetes.Endpoints.Setting;
public class GetSettingRequest
{

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
namespace PyroFetes.Endpoints.Setting;
public class PatchSettingElectronicSignatureEndpoint(PyroFetesDbContext database) : Endpoint<PatchSettingElectronicSignatureDto, GetSettingDto>
{
public override void Configure()
{
Get("/api/setting/{@Id}/ElectronicSignature", x => new {x.Id});
}
public override async Task HandleAsync(PatchSettingElectronicSignatureDto req, CancellationToken ct)
{
var setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (setting == null)
{
await Send.NotFoundAsync(ct);
return;
}
setting.ElectronicSignature = req.ElectronicSignature;
await database.SaveChangesAsync(ct);
GetSettingDto responseDto = new()
{
Id = setting.Id,
ElectronicSignature = setting.ElectronicSignature,
Logo = setting.Logo
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -0,0 +1,37 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
namespace PyroFetes.Endpoints.Setting;
public class PatchSettingLogoEndpoint(PyroFetesDbContext database) : Endpoint<PatchSettingLogoDto, GetSettingDto>
{
public override void Configure()
{
Get("/api/setting/{@Id}/Logo", x => new {x.Id});
}
public override async Task HandleAsync(PatchSettingLogoDto req, CancellationToken ct)
{
var setting = await database.Settings.SingleOrDefaultAsync(x => x.Id == req.Id, ct);
if (setting == null)
{
await Send.NotFoundAsync(ct);
return;
}
setting.Logo = req.Logo;
await database.SaveChangesAsync(ct);
GetSettingDto responseDto = new()
{
Id = setting.Id,
ElectronicSignature = setting.ElectronicSignature,
Logo = setting.Logo
};
await Send.OkAsync(responseDto, ct);
}
}

View File

@@ -1,8 +1,9 @@
namespace PyroFetes.Endpoint.Setting;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.DTO.SettingDTO.Response;
namespace PyroFetes.Endpoints.Setting;
public class UpdateSettingEndpoint(PyroFetesDbContext database) : Endpoint<UpdateSettingDto, GetSettingDto>
{