forked from sanchezvem/PyroFetes
09/10
This commit is contained in:
31
PyroFetes/Endpoints/Movement/GetAllMovementsEndpoint.cs
Normal file
31
PyroFetes/Endpoints/Movement/GetAllMovementsEndpoint.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using API.DTO.Movement.Response;
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace PyroFetes.Endpoints.Movement;
|
||||
|
||||
public class GetAllMovementsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMovementDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/movements");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
|
||||
List<GetMovementDto> responseDto = await pyrofetesdbcontext.Movements
|
||||
.Select(a => new GetMovementDto
|
||||
{
|
||||
Id = a.Id,
|
||||
Date = a.Date,
|
||||
Start = a.Start,
|
||||
Arrival = a.Arrival,
|
||||
Quantity = a.Quantity
|
||||
}
|
||||
).ToListAsync(ct);
|
||||
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user