Skip to content

Commit 4bae077

Browse files
committed
Update 02-customize-a-pizza
1 parent b8e84c4 commit 4bae077

22 files changed

+203
-116
lines changed

docs/02-customize-a-pizza.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ The user should also be able to select additional toppings on `ConfigurePizzaDia
186186

187187
protected async override Task OnInitializedAsync()
188188
{
189-
toppings = await HttpClient.GetJsonAsync<List<Topping>>("toppings");
189+
toppings = await HttpClient.GetFromJsonAsync<List<Topping>>("toppings");
190190
}
191191
}
192192
```
@@ -402,7 +402,7 @@ void RemoveConfiguredPizza(Pizza pizza)
402402

403403
async Task PlaceOrder()
404404
{
405-
await HttpClient.PostJsonAsync("orders", order);
405+
await HttpClient.PostAsJsonAsync("orders", order);
406406
order = new Order();
407407
}
408408
```

save-points/02-customize-a-pizza/BlazingPizza.Client/App.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</Found>
55
<NotFound>
66
<LayoutView Layout="typeof(MainLayout)">
7-
<div class="main">Page not found</div>
7+
<div class="main">Sorry, there's nothing at this address.</div>
88
</LayoutView>
99
</NotFound>
1010
</Router>

save-points/02-customize-a-pizza/BlazingPizza.Client/BlazingPizza.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(BlazorVersion)" />
1111
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="$(BlazorVersion)" PrivateAssets="all" />
12-
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="$(BlazorVersion)" />
13-
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="$(AspNetCoreVersion)" />
12+
<PackageReference Include="System.Net.Http.Json" Version="$(SystemNetHttpJsonVersion)" />
13+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="$(BlazorVersion)" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

save-points/02-customize-a-pizza/BlazingPizza.Client/Pages/Index.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
protected override async Task OnInitializedAsync()
6363
{
64-
specials = await HttpClient.GetJsonAsync<List<PizzaSpecial>>("specials");
64+
specials = await HttpClient.GetFromJsonAsync<List<PizzaSpecial>>("specials");
6565
}
6666

6767
void ShowConfigurePizzaDialog(PizzaSpecial special)
@@ -98,7 +98,7 @@
9898

9999
async Task PlaceOrder()
100100
{
101-
await HttpClient.PostJsonAsync("orders", order);
101+
await HttpClient.PostAsJsonAsync("orders", order);
102102
order = new Order();
103103
}
104104
}

save-points/02-customize-a-pizza/BlazingPizza.Client/Shared/ConfigurePizzaDialog.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
protected async override Task OnInitializedAsync()
7171
{
72-
toppings = await HttpClient.GetJsonAsync<List<Topping>>("toppings");
72+
toppings = await HttpClient.GetFromJsonAsync<List<Topping>>("toppings");
7373
}
7474

7575
void ToppingSelected(ChangeEventArgs e)

save-points/02-customize-a-pizza/BlazingPizza.Client/Shared/MainLayout.razor

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
@inherits LayoutComponentBase
22

33
<div class="top-bar">
4-
<img class="logo" src="img/logo.svg" />
4+
<a class="logo" href="">
5+
<img src="img/logo.svg" />
6+
</a>
57

68
<NavLink href="" class="nav-tab" Match="NavLinkMatch.All">
79
<img src="img/pizza-slice.svg" />

save-points/02-customize-a-pizza/BlazingPizza.Client/_Imports.razor

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
@using System.Net.Http
2+
@using System.Net.Http.Headers
3+
@using System.Net.Http.Json
24
@using Microsoft.AspNetCore.Authorization
35
@using Microsoft.AspNetCore.Components.Authorization
46
@using Microsoft.AspNetCore.Components.Forms
57
@using Microsoft.AspNetCore.Components.Routing
68
@using Microsoft.AspNetCore.Components.Web
9+
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
710
@using Microsoft.JSInterop
811
@using BlazingPizza.Client
912
@using BlazingPizza.Client.Shared

save-points/02-customize-a-pizza/BlazingPizza.Client/wwwroot/css/site.css

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ form {
3636
}
3737

3838
.logo {
39-
margin-right: 3rem;
40-
width: 9rem;
39+
display: flex;
4140
}
4241

42+
.logo > img {
43+
margin-right: 3rem;
44+
width: 9rem;
45+
}
46+
4347
.content {
4448
display: flex;
4549
height: 100%;
@@ -120,13 +124,21 @@ form {
120124
font-weight: 700;
121125
line-height: 0.7rem;
122126
margin-top: 0.5rem;
127+
color: white;
128+
font-size: 1rem;
123129
}
124130

125131
.user-info a {
126132
color: #fff2cc;
127133
font-size: 0.8rem;
128134
}
129135

136+
.user-info button.sign-out {
137+
color: #fff2cc;
138+
font-size: 0.8rem;
139+
padding: 0;
140+
}
141+
130142
.pizza-cards {
131143
display: grid;
132144
grid-template-columns: repeat(auto-fill, 20rem);
@@ -540,6 +552,7 @@ a.sign-in {
540552
font-weight: 100;
541553
cursor: pointer;
542554
transition: 0.2s ease-out;
555+
margin-left: 3px;
543556
}
544557

545558
a.sign-in:hover {
@@ -548,16 +561,6 @@ a.sign-in {
548561
border-color: #fff2cc;
549562
}
550563

551-
.user-info a.sign-out {
552-
color: #fff2cc;
553-
font-size: 0.8rem;
554-
cursor: pointer;
555-
}
556-
557-
.user-info a.sign-out:hover {
558-
text-decoration: underline;
559-
}
560-
561564
input[type=range] {
562565
-webkit-appearance: none;
563566
margin: 7.1px 0;
@@ -721,6 +724,25 @@ input[type=range] {
721724
color: red;
722725
}
723726

727+
#blazor-error-ui {
728+
background: lightyellow;
729+
bottom: 0;
730+
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
731+
display: none;
732+
left: 0;
733+
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
734+
position: fixed;
735+
width: 100%;
736+
z-index: 1000;
737+
}
738+
739+
#blazor-error-ui .dismiss {
740+
cursor: pointer;
741+
position: absolute;
742+
right: 0.75rem;
743+
top: 0.5rem;
744+
}
745+
724746
@keyframes progressbar-slide {
725747
0% {
726748
transform: translateX(-200px);
@@ -733,4 +755,4 @@ input[type=range] {
733755
100% {
734756
transform: translateX(500px);
735757
}
736-
}
758+
}

save-points/02-customize-a-pizza/BlazingPizza.Client/wwwroot/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
<div class="loading-bar"></div>
1616
</app>
1717

18+
<div id="blazor-error-ui">
19+
An unhandled error has occurred.
20+
<a href="" class="reload">Reload</a>
21+
<a class="dismiss">🗙</a>
22+
</div>
23+
1824
<script src="_framework/blazor.webassembly.js"></script>
1925
<script src="_content/BlazingPizza.ComponentsLibrary/localStorage.js"></script>
2026
<script src="_content/BlazingPizza.ComponentsLibrary/pushNotifications.js"></script>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@using Microsoft.AspNetCore.Identity
2+
@using BlazingPizza.Server
3+
@inject SignInManager<PizzaStoreUser> SignInManager
4+
@inject UserManager<PizzaStoreUser> UserManager
5+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
6+
7+
@{
8+
var returnUrl = "/";
9+
if (Context.Request.Query.TryGetValue("returnUrl", out var existingUrl))
10+
{
11+
returnUrl = existingUrl;
12+
}
13+
}
14+
15+
<div class="user-info">
16+
@if (SignInManager.IsSignedIn(User))
17+
{
18+
<img src="~/img/user.svg" />
19+
<div>
20+
<a class="username" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">@User.Identity.Name</a>
21+
<form asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/" method="post">
22+
<button type="submit" class="btn btn-link sign-out">Sign out</button>
23+
</form>
24+
</div>
25+
}
26+
else
27+
{
28+
<a class="sign-in" asp-area="Identity" asp-page="/Account/Register" asp-route-returnUrl="@returnUrl">Register</a>
29+
<a class="sign-in" asp-area="Identity" asp-page="/Account/Login" asp-route-returnUrl="@returnUrl">Login</a>
30+
}
31+
</div>

0 commit comments

Comments
 (0)