This commit is contained in:
commit
1199bef0c8
1 changed files with 1200 additions and 0 deletions
20
src/Core/Vehicles/GetVehicleEndpoint.cs
Normal file
20
src/Core/Vehicles/GetVehicleEndpoint.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
namespace TestWeb.Core.Vehicles;
|
||||
|
||||
using Infra;
|
||||
|
||||
public static class GetVehicleEndpoint
|
||||
{
|
||||
public static async Task<Results<Ok<Vehicle>, NotFound>> Handle(
|
||||
int id,
|
||||
AppDbContext db,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var result = await db.Vehicles
|
||||
.Where(x => x.Id == id)
|
||||
.SingleOrDefaultAsync(ct);
|
||||
|
||||
return result is null
|
||||
? TypedResults.NotFound()
|
||||
: TypedResults.Ok(result);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue