forked from sanchezvem/PyroFetes
Creating all setting's endpoints
This commit is contained in:
32
PyroFetes/Endpoints/Setting/CreateSettingEndpoint.cs
Normal file
32
PyroFetes/Endpoints/Setting/CreateSettingEndpoint.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using PyroFetes.DTO.SettingDTO.Request;
|
||||
using PyroFetes.DTO.SettingDTO.Response;
|
||||
using FastEndpoints;
|
||||
namespace PyroFetes.Endpoints.Setting;
|
||||
|
||||
public class CreateSettingEndpoint(PyroFetesDbContext database) : Endpoint<CreateSettingDto, GetSettingDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/setting");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateSettingDto req, CancellationToken ct)
|
||||
{
|
||||
var setting = new Models.Setting()
|
||||
{
|
||||
ElectronicSignature = req.ElectronicSignature,
|
||||
Logo = req.Logo
|
||||
};
|
||||
|
||||
database.Settings.Add(setting);
|
||||
await database.SaveChangesAsync(ct);
|
||||
|
||||
GetSettingDto responseDto = new()
|
||||
{
|
||||
Id = setting.Id,
|
||||
ElectronicSignature = setting.ElectronicSignature,
|
||||
Logo = setting.Logo
|
||||
};
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user