Rename WebApi project to Vegasco.Server.Api
All checks were successful
continuous-integration/drone/push Build is passing

And update all references including comments etc.
This commit is contained in:
2025-06-12 18:22:37 +02:00
parent 9d71c86474
commit a1999bfe41
71 changed files with 177 additions and 224 deletions

View File

@@ -0,0 +1,46 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.Server.Api.Cars;
public static class GetCars
{
public class ApiResponse
{
public IEnumerable<ResponseDto> Cars { get; set; } = [];
}
public record ResponseDto(Guid Id, string Name);
public class Request
{
[FromQuery(Name = "page")] public int? Page { get; set; }
[FromQuery(Name = "pageSize")] public int? PageSize { get; set; }
}
public static RouteHandlerBuilder MapEndpoint(IEndpointRouteBuilder builder)
{
return builder
.MapGet("cars", Endpoint)
.WithDescription("Returns all cars")
.WithTags("Cars");
}
private static async Task<Ok<ApiResponse>> Endpoint(
[AsParameters] Request request,
ApplicationDbContext dbContext,
CancellationToken cancellationToken)
{
List<ResponseDto> cars = await dbContext.Cars
.Select(x => new ResponseDto(x.Id.Value, x.Name))
.ToListAsync(cancellationToken);
var response = new ApiResponse
{
Cars = cars
};
return TypedResults.Ok(response);
}
}