Skip to content

Commit 9579e78

Browse files
committed
sample: check for auth on blazing pizza pages, attach address to order
1 parent 22afed8 commit 9579e78

File tree

7 files changed

+1163
-204
lines changed

7 files changed

+1163
-204
lines changed

samples/BlazingPizza/Components/Pages/Checkout.razor

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/checkout"
2+
@attribute [Authorize]
23
@inject PizzaClient PizzaClient
34
@inject OrdersClient OrdersClient
45
@inject NavigationManager NavigationManager
@@ -49,30 +50,30 @@
4950
protected override async Task OnInitializedAsync()
5051
{
5152
Address ??= new Address();
52-
5353
specials = await PizzaClient.GetSpecials();
5454
toppings = await PizzaClient.GetToppings();
5555

5656
foreach (var special in OrderForm?.Pizzas ?? Enumerable.Empty<ConfigurePizzaFormData>())
5757
{
5858
AddPizza(special);
5959
}
60+
61+
order.DeliveryAddress = Address;
6062
}
6163

6264
private void AddPizza(ConfigurePizzaFormData form)
6365
{
6466
order.Pizzas.Add(new Pizza
67+
{
68+
Size = form.Size,
69+
SpecialId = form.SpecialId,
70+
Special = specials.Single(x => x.Id == form.SpecialId),
71+
Toppings = form.Toppings?.Select(toppingId => new PizzaTopping
6572
{
66-
Id = order.Pizzas.Count + 1,
67-
Size = form.Size,
68-
SpecialId = form.SpecialId,
69-
Special = specials.Single(x => x.Id == form.SpecialId),
70-
Toppings = form.Toppings?.Select(toppingId => new PizzaTopping
71-
{
72-
ToppingId = toppingId,
73-
Topping = toppings.Single(x => x.Id == toppingId)
74-
}).ToList() ?? [],
75-
});
73+
ToppingId = toppingId,
74+
Topping = toppings.Single(x => x.Id == toppingId)
75+
}).ToList() ?? [],
76+
});
7677
}
7778

7879
private async Task PlaceOrder()

samples/BlazingPizza/Components/Pages/MyOrders.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/myorders"
2+
@attribute [Authorize]
23
@inject OrdersClient OrdersClient
34

45
<PageTitle>Blazing Pizza - My Orders</PageTitle>

samples/BlazingPizza/Components/Pages/OrderDetails.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@implements IDisposable
2+
@attribute [Authorize]
23
@page "/myorders/{orderId:int}"
34
@inject OrdersClient OrdersClient
45

0 commit comments

Comments
 (0)