forked from sanchezvem/PyroFetes
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			873 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			873 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| 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);
 | |
|     }
 | |
| } |