From 277548586c001b1d992fc36f80534badfea291a9 Mon Sep 17 00:00:00 2001 From: Mark J Price Date: Thu, 15 Dec 2022 08:56:20 +0000 Subject: [PATCH] Errata for page 641 --- docs/errata/README.md | 2 +- docs/errata/errata.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/errata/README.md b/docs/errata/README.md index 7b93d57..990496a 100644 --- a/docs/errata/README.md +++ b/docs/errata/README.md @@ -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. diff --git a/docs/errata/errata.md b/docs/errata/errata.md index bd177d5..572a2ca 100644 --- a/docs/errata/errata.md +++ b/docs/errata/errata.md @@ -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
Category
@@ -196,6 +199,22 @@ But since the `Category` and `UnitPrice` properties could be null, we should use
@(Model.UnitPrice is null ? "zero" : Model.UnitPrice.Value.ToString("C"))
``` +# 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).