From 362b5f3186ba1a7a14bae5835e33e68d619c294a Mon Sep 17 00:00:00 2001 From: Adam SP Date: Wed, 14 Feb 2024 15:40:36 +1100 Subject: [PATCH] Lab 4 fixes (#26) * Corrected example code for wiring the `BasketService` to the GRPC project * Corrected incorrect initialisation/construction of `CustomerBasket` * Corrected spelling of `ConfigureDefaultJwtBearer` in explanation * Corrected incomplete accessor on sample method `ThrowBasketDoesNotExist` * Updated the `CartPage` CSS to make the behaviour of the `Update` button align with other "buttons" on hover --- labs/4-Add-Shopping-Basket/README.md | 11 +++++++---- .../WebApp/Components/Pages/Cart/CartPage.razor.css | 6 ++++++ .../WebApp/Components/Pages/Cart/CartPage.razor.css | 6 ++++++ .../WebApp/Components/Pages/Cart/CartPage.razor.css | 6 ++++++ .../WebApp/Components/Pages/Cart/CartPage.razor.css | 6 ++++++ .../WebApp/Components/Pages/Cart/CartPage.razor.css | 6 ++++++ src/WebApp/Components/Pages/Cart/CartPage.razor.css | 6 ++++++ 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/labs/4-Add-Shopping-Basket/README.md b/labs/4-Add-Shopping-Basket/README.md index c13c414..2771c40 100644 --- a/labs/4-Add-Shopping-Basket/README.md +++ b/labs/4-Add-Shopping-Basket/README.md @@ -160,7 +160,7 @@ In previous labs, we have created a web site that shoppers can use to browser a 1. In the `Program.cs` file, update the line that maps the `GreeterService` gRPC service so that it maps the `BasketService` instead: ```csharp - builder.MapGrpcService(); + app.MapGrpcService(); ``` 1. Delete the `Services/GreeterSrevice.cs` file that was included with the template, including the `Services` directory. @@ -293,7 +293,10 @@ In previous labs, we have created a web site that shoppers can use to browser a private static CustomerBasket MapToCustomerBasket(string userId, UpdateBasketRequest customerBasketRequest) { - var response = new CustomerBasket(userId); + var response = new CustomerBasket + { + BuyerId = userId + }; foreach (var item in customerBasketRequest.Items) { @@ -379,7 +382,7 @@ In previous labs, we have created a web site that shoppers can use to browser a 1. Navigate to the definition of the `AddDefaultAuthentication` method and take a moment to read through the code. This code looks similar in places to the authentication configuration code in the `WebApp` project added in lab 3, but is slightly simpler as it doesn't need to configure the application to instigate login flows via OpenID Connect. It just needs to validate tokens issued by the IdP. - Note that the `ConfigureDefaaultJwtBearer` method expects the application configuration to have a section named **Identity** from which it retrieves a required value named **Audience**. This code will throw a runtime extepsion if it doesn't exist, so let's add that now. + Note that the `ConfigureDefaultJwtBearer` method expects the application configuration to have a section named **Identity** from which it retrieves a required value named **Audience**. This code will throw a runtime extepsion if it doesn't exist, so let's add that now. 1. Open the `appsettings.json` file and add a new section named **Identity** with a property named **Audience** set to a value of `"basket"`: @@ -418,7 +421,7 @@ In previous labs, we have created a web site that shoppers can use to browser a } [DoesNotReturn] - rivate static void ThrowBasketDoesNotExist(string userId) + private static void ThrowBasketDoesNotExist(string userId) => throw new RpcException(new Status(StatusCode.NotFound, $"Basket with buyer ID {userId} does not exist")); ``` diff --git a/labs/4-Add-Shopping-Basket/end/WebApp/Components/Pages/Cart/CartPage.razor.css b/labs/4-Add-Shopping-Basket/end/WebApp/Components/Pages/Cart/CartPage.razor.css index 24efa47..cc34156 100644 --- a/labs/4-Add-Shopping-Basket/end/WebApp/Components/Pages/Cart/CartPage.razor.css +++ b/labs/4-Add-Shopping-Basket/end/WebApp/Components/Pages/Cart/CartPage.razor.css @@ -52,6 +52,12 @@ gap: 0.5rem; } +.cart-items .cart-item .catalog-item-quantity form button:hover { + cursor: pointer; + background: #000; + color: #FFF; +} + .cart-items .cart-item .catalog-item-quantity input { max-width: 3rem; padding: 1rem 0.75rem; diff --git a/labs/4-Add-Shopping-Basket/src/WebApp/Components/Pages/Cart/CartPage.razor.css b/labs/4-Add-Shopping-Basket/src/WebApp/Components/Pages/Cart/CartPage.razor.css index 24efa47..cc34156 100644 --- a/labs/4-Add-Shopping-Basket/src/WebApp/Components/Pages/Cart/CartPage.razor.css +++ b/labs/4-Add-Shopping-Basket/src/WebApp/Components/Pages/Cart/CartPage.razor.css @@ -52,6 +52,12 @@ gap: 0.5rem; } +.cart-items .cart-item .catalog-item-quantity form button:hover { + cursor: pointer; + background: #000; + color: #FFF; +} + .cart-items .cart-item .catalog-item-quantity input { max-width: 3rem; padding: 1rem 0.75rem; diff --git a/labs/5-Add-Checkout/end/WebApp/Components/Pages/Cart/CartPage.razor.css b/labs/5-Add-Checkout/end/WebApp/Components/Pages/Cart/CartPage.razor.css index 24efa47..cc34156 100644 --- a/labs/5-Add-Checkout/end/WebApp/Components/Pages/Cart/CartPage.razor.css +++ b/labs/5-Add-Checkout/end/WebApp/Components/Pages/Cart/CartPage.razor.css @@ -52,6 +52,12 @@ gap: 0.5rem; } +.cart-items .cart-item .catalog-item-quantity form button:hover { + cursor: pointer; + background: #000; + color: #FFF; +} + .cart-items .cart-item .catalog-item-quantity input { max-width: 3rem; padding: 1rem 0.75rem; diff --git a/labs/5-Add-Checkout/src/WebApp/Components/Pages/Cart/CartPage.razor.css b/labs/5-Add-Checkout/src/WebApp/Components/Pages/Cart/CartPage.razor.css index 24efa47..cc34156 100644 --- a/labs/5-Add-Checkout/src/WebApp/Components/Pages/Cart/CartPage.razor.css +++ b/labs/5-Add-Checkout/src/WebApp/Components/Pages/Cart/CartPage.razor.css @@ -52,6 +52,12 @@ gap: 0.5rem; } +.cart-items .cart-item .catalog-item-quantity form button:hover { + cursor: pointer; + background: #000; + color: #FFF; +} + .cart-items .cart-item .catalog-item-quantity input { max-width: 3rem; padding: 1rem 0.75rem; diff --git a/labs/6-Add-Resiliency/src/WebApp/Components/Pages/Cart/CartPage.razor.css b/labs/6-Add-Resiliency/src/WebApp/Components/Pages/Cart/CartPage.razor.css index 24efa47..cc34156 100644 --- a/labs/6-Add-Resiliency/src/WebApp/Components/Pages/Cart/CartPage.razor.css +++ b/labs/6-Add-Resiliency/src/WebApp/Components/Pages/Cart/CartPage.razor.css @@ -52,6 +52,12 @@ gap: 0.5rem; } +.cart-items .cart-item .catalog-item-quantity form button:hover { + cursor: pointer; + background: #000; + color: #FFF; +} + .cart-items .cart-item .catalog-item-quantity input { max-width: 3rem; padding: 1rem 0.75rem; diff --git a/src/WebApp/Components/Pages/Cart/CartPage.razor.css b/src/WebApp/Components/Pages/Cart/CartPage.razor.css index 24efa47..cc34156 100644 --- a/src/WebApp/Components/Pages/Cart/CartPage.razor.css +++ b/src/WebApp/Components/Pages/Cart/CartPage.razor.css @@ -52,6 +52,12 @@ gap: 0.5rem; } +.cart-items .cart-item .catalog-item-quantity form button:hover { + cursor: pointer; + background: #000; + color: #FFF; +} + .cart-items .cart-item .catalog-item-quantity input { max-width: 3rem; padding: 1rem 0.75rem;