Creating setting's endpoints
This commit is contained in:
27
PyroFetes/Endpoints/Setting/GetAllSettingEndpoint.cs
Normal file
27
PyroFetes/Endpoints/Setting/GetAllSettingEndpoint.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace PyroFetes.Endpoints.Setting;
|
||||
using PyroFetes.DTO.SettingDTO.Request;
|
||||
using PyroFetes.DTO.SettingDTO.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public class GetAllSettingEndpoint(PyroFetesDbContext database) : EndpointWithoutRequest<List<GetSettingDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/setting");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
var setting = await database.Settings
|
||||
.Select(setting => new GetSettingDto()
|
||||
{
|
||||
Id = setting.Id,
|
||||
ElectronicSignature = setting.ElectronicSignature,
|
||||
Logo = setting.Logo
|
||||
})
|
||||
.ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(setting, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user