forked from sanchezvem/PyroFetes
34 lines
783 B
C#
34 lines
783 B
C#
using API.DTO.Brand.Request;
|
|
using API.DTO.Brand.Response;
|
|
using FastEndpoints;
|
|
|
|
namespace PyroFetes.Endpoints.Brand;
|
|
|
|
public class UpdateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateBrandDto, GetBrandDto>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Post("/api/brands");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(UpdateBrandDto req, CancellationToken ct)
|
|
{
|
|
|
|
Models.Brand brand = new()
|
|
{
|
|
Name = req.Name
|
|
};
|
|
pyrofetesdbcontext.Add(brand);
|
|
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
|
|
|
GetBrandDto response = new()
|
|
{
|
|
Id = req.Id,
|
|
Name = req.Name
|
|
};
|
|
|
|
await Send.OkAsync(response, ct);
|
|
|
|
}
|
|
} |