Skip to content

Commit

Permalink
Lab 4 fixes (#26)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SmithPlatts authored Feb 14, 2024
1 parent d0cfc53 commit 362b5f3
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 4 deletions.
11 changes: 7 additions & 4 deletions labs/4-Add-Shopping-Basket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<BasketService>();
app.MapGrpcService<BasketService>();
```

1. Delete the `Services/GreeterSrevice.cs` file that was included with the template, including the `Services` directory.
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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"`:

Expand Down Expand Up @@ -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"));
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/WebApp/Components/Pages/Cart/CartPage.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 362b5f3

Please sign in to comment.