commit
7a809d4e1b
|
@ -196,7 +196,7 @@ We expect library authors to continue targeting `IHostBuilder`, `IWebHostBuilder
|
|||
|
||||
## Blazor
|
||||
|
||||
To adopt all of the new 6.0 features for Blazor apps, we recommend the following process:
|
||||
To adopt all of the [new 6.0 features for Blazor apps](xref:aspnetcore-6.0#blazor), we recommend the following process:
|
||||
|
||||
* Create a new 6.0 Blazor project from one of the Blazor project templates. For more information, see <xref:blazor/tooling>.
|
||||
* Move the app's components and code to the 6.0 app making modifications to adopt the new 6.0 features.
|
||||
|
|
|
@ -419,7 +419,7 @@ A DTO may be used to:
|
|||
|
||||
To demonstrate the DTO approach, update the `Todo` class to include a secret field:
|
||||
|
||||
[!code-csharp[](min-web-api/samples/6.x/todoDTO/Program.cs?name=snippet_secret&highlight=7)]
|
||||
[!code-csharp[](min-web-api/samples/6.x/todoDTO/Program.cs?name=snippet_secret&highlight=6)]
|
||||
|
||||
The secret field needs to be hidden from this app, but an administrative app could choose to expose it.
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ app.MapPost("/todoitems", async (TodoItemDTO todoItemDTO, TodoDb db) =>
|
|||
db.Todos.Add(todoItem);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
return Results.Created($"/todoitems/{todoItem.Id}", todoItem);
|
||||
return Results.Created($"/todoitems/{todoItem.Id}", new TodoItemDTO(todoItem));
|
||||
});
|
||||
|
||||
#region snippet_put
|
||||
|
@ -53,7 +53,7 @@ app.MapDelete("/todoitems/{id}", async (int id, TodoDb db) =>
|
|||
{
|
||||
db.Todos.Remove(todo);
|
||||
await db.SaveChangesAsync();
|
||||
return Results.Ok(todo);
|
||||
return Results.Ok(new TodoItemDTO(todo));
|
||||
}
|
||||
|
||||
return Results.NotFound();
|
||||
|
@ -74,6 +74,7 @@ public class Todo
|
|||
#region snippet_DTO
|
||||
public class TodoItemDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool IsComplete { get; set; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue