Add item for page 673

This commit is contained in:
Mark J Price 2023-06-12 07:37:25 +01:00
parent aebc77ab4c
commit 1bc725692e
2 changed files with 16 additions and 2 deletions

View file

@ -4,7 +4,7 @@ If you find any mistakes in the seventh edition, *C# 11 and .NET 7 - Modern Cros
[**Errata** (44 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
[**Improvements** (37 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
[**Improvements** (38 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
[**Common Errors** (6 items)](common-errors.md): These are some of the most common errors that a reader might encounter when trying to get code in book tasks to work, or when trying to write your own code.

View file

@ -1,4 +1,4 @@
**Improvements** (37 items)
**Improvements** (38 items)
If you have suggestions for improvements, then please [raise an issue in this repository](https://github.com/markjprice/cs11dotnet7/issues) or email me at markjprice (at) gmail.com.
@ -39,6 +39,7 @@ If you have suggestions for improvements, then please [raise an issue in this re
- [Page 650 - Varying cached data by query string](#page-650---varying-cached-data-by-query-string)
- [Page 654 - Making controller action methods asynchronous](#page-654---making-controller-action-methods-asynchronous)
- [Page 655 - Exercise 14.2 Practice implementing MVC by implementing a category detail page](#page-655---exercise-142--practice-implementing-mvc-by-implementing-a-category-detail-page)
- [Page 673 - Configuring the customer repository and Web API controller](#page-673---configuring-the-customer-repository-and-web-api-controller)
- [Page 700 - Exercise 15.2 Practice creating and deleting customers with HttpClient](#page-700---exercise-152--practice-creating-and-deleting-customers-with-httpclient)
# Page 25 - Adding a second project using Visual Studio 2022
@ -1045,6 +1046,19 @@ If you want to keep the original link format, then you would need to decorate th
public async Task<IActionResult> CategoryDetail(int? id)
```
# Page 673 - Configuring the customer repository and Web API controller
In Step 4, you add a `CustomersController.cs` file and define a `CustomersController` class, as shown in the following partial code:
```cs
// base address: api/customers
[Route("api/[controller]")]
[ApiController]
public class CustomersController : ControllerBase
{
```
In the next edition, I will add more explanation about how the route is defined by the `[Route]` attribute. The `[controller]` part is automatically replaced with the class name with the `Controller` suffix removed. Therefore the base address of the route to the `CustomersController` is `api/customers`.
# Page 700 - Exercise 15.2 Practice creating and deleting customers with HttpClient
In this exercise, you are tasked to "extend the `Northwind.Mvc` website project to have pages where a visitor can fill in a form to create a new customer, or search for a customer and then delete them. The MVC controller should make calls to the Northwind web service to create and delete customers."