format sample (#30)

pull/31/head
Rick Anderson 2022-09-01 15:11:22 -10:00 committed by GitHub
parent e413883cb9
commit bef98a31c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -11,7 +11,8 @@ app.MapGet("/todoitems", async (TodoDb db) =>
await db.Todos.Select(x => new TodoItemDTO(x)).ToListAsync()); await db.Todos.Select(x => new TodoItemDTO(x)).ToListAsync());
// <snippet_id> // <snippet_id>
app.MapGet("/todoitems/{id}", async (int Id, TodoDb Db) => app.MapGet("/todoitems/{id}",
async (int Id, TodoDb Db) =>
await Db.Todos.FindAsync(Id) await Db.Todos.FindAsync(Id)
is Todo todo is Todo todo
? Results.Ok(new TodoItemDTO(todo)) ? Results.Ok(new TodoItemDTO(todo))
@ -68,7 +69,8 @@ app.MapDelete("/todoitems/{id}", async (int Id, TodoDb Db) =>
// --- [AsParameters] go here ---------------------- // --- [AsParameters] go here ----------------------
// <snippet_ap_id> // <snippet_ap_id>
app.MapGet("/ap/todoitems/{id}", async ([AsParameters] TodoItemRequest request) => app.MapGet("/ap/todoitems/{id}",
async ([AsParameters] TodoItemRequest request) =>
await request.Db.Todos.FindAsync(request.Id) await request.Db.Todos.FindAsync(request.Id)
is Todo todo is Todo todo
? Results.Ok(new TodoItemDTO(todo)) ? Results.Ok(new TodoItemDTO(todo))