Errata for page 641

This commit is contained in:
Mark J Price 2022-12-15 08:56:20 +00:00
parent b1e9462227
commit 277548586c
2 changed files with 20 additions and 1 deletions

View file

@ -2,7 +2,7 @@
If you find any mistakes in the seventh edition, *C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals*, or 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.
[**Errata** (14 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
[**Errata** (15 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
[**Improvements** (1 item)](improvements.md): Changes to text or code that would improve the content. These are optional.

View file

@ -18,6 +18,7 @@ If you find any mistakes, then please [raise an issue in this repository](https:
- [Page 477 - Inserting entities](#page-477---inserting-entities)
- [Page 627 - Defining a typed view](#page-627---defining-a-typed-view)
- [Page 631 - Passing parameters using a route value](#page-631---passing-parameters-using-a-route-value)
- [Page 641 - Enabling role management and creating a role programmatically](#page-641---enabling-role-management-and-creating-a-role-programmatically)
- [Page 649 - Varying cached data by query string](#page-649---varying-cached-data-by-query-string)
# Page 4, 8 - Pros and cons of the .NET Interactive Notebooks extension, Downloading and installing Visual Studio Code
@ -181,6 +182,8 @@ It was already correct in the GitHub copy of the code.
# Page 631 - Passing parameters using a route value
> Thanks to Bob Molloy for raising this issue via email.
In Step 3, the statements attempt to output the values of the category name and unit price for the product, as shown in the following markup:
```xml
<dt>Category</dt>
@ -196,6 +199,22 @@ But since the `Category` and `UnitPrice` properties could be null, we should use
<dd>@(Model.UnitPrice is null ? "zero" : Model.UnitPrice.Value.ToString("C"))</dd>
```
# Page 641 - Enabling role management and creating a role programmatically
> Thanks to Bob Molloy for raising this issue via email.
In Step 2, in the `Index` action method, the variable declaration for finding the email of the use is not nullable, as shown in the following code:
```cs
IdentityUser user = await userManager.FindByEmailAsync(UserEmail);
```
It should be nullable, as shown in the following code:
```cs
IdentityUser? user = await userManager.FindByEmailAsync(UserEmail);
```
It was already correct in the GitHub copy of the code.
# Page 649 - Varying cached data by query string
> Thanks to [Chadwick Geyser](https://github.com/chadwickgeyser) for raising this [issue on 5 December 2022](https://github.com/markjprice/cs11dotnet7/issues/7).