Skip to content

Commit

Permalink
Errata for page 631
Browse files Browse the repository at this point in the history
  • Loading branch information
markjprice committed Dec 14, 2022
1 parent a0de8af commit b1e9462
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/errata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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** (13 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
[**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.

[**Improvements** (1 item)](improvements.md): Changes to text or code that would improve the content. These are optional.

Expand Down
20 changes: 19 additions & 1 deletion docs/errata/errata.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**Errata** (13 items)
**Errata** (14 items)

If you find any mistakes, then please [raise an issue in this repository](https://github.com/markjprice/cs11dotnet7/issues) or email me at markjprice (at) gmail.com.

Expand All @@ -17,6 +17,7 @@ If you find any mistakes, then please [raise an issue in this repository](https:
- [Page 412 - Compressing streams](#page-412---compressing-streams)
- [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 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
Expand Down Expand Up @@ -178,6 +179,23 @@ Should be `data-bs-slide-to`, as shown in the following markup:

It was already correct in the GitHub copy of the code.

# Page 631 - Passing parameters using a route value

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>
<dd>@Model.CategoryId - @Model.Category.CategoryName</dd>
<dt>Unit Price</dt>
<dd>@Model.UnitPrice.Value.ToString("C")</dd>
```
But since the `Category` and `UnitPrice` properties could be null, we should use a null checks, as shown in the following markup:
```xml
<dt>Category</dt>
<dd>@Model.CategoryId - @Model.Category?.CategoryName</dd>
<dt>Unit Price</dt>
<dd>@(Model.UnitPrice is null ? "zero" : Model.UnitPrice.Value.ToString("C"))</dd>
```

# 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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<dt>Product Name</dt>
<dd>@Model.ProductName</dd>
<dt>Category</dt>
<dd>@Model.CategoryId - @Model.Category.CategoryName</dd>
<dd>@Model.CategoryId - @Model.Category?.CategoryName</dd>
<dt>Unit Price</dt>
<dd>@Model.UnitPrice.Value.ToString("C")</dd>
<dd>@(Model.UnitPrice is null ? "zero" : Model.UnitPrice.Value.ToString("C"))</dd>
<dt>Units In Stock</dt>
<dd>@Model.UnitsInStock</dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<dt>Product Name</dt>
<dd>@Model.ProductName</dd>
<dt>Category</dt>
<dd>@Model.CategoryId - @Model.Category.CategoryName</dd>
<dd>@Model.CategoryId - @Model.Category?.CategoryName</dd>
<dt>Unit Price</dt>
<dd>@Model.UnitPrice.Value.ToString("C")</dd>
<dd>@(Model.UnitPrice is null ? "zero" : Model.UnitPrice.Value.ToString("C"))</dd>
<dt>Units In Stock</dt>
<dd>@Model.UnitsInStock</dd>
</dl>
Expand Down

0 comments on commit b1e9462

Please sign in to comment.