Skip to content
Permalink
Browse files

Upgrade to 3.0.0-preview4-19216-03

  • Loading branch information...
SQL-MisterMagoo committed Apr 26, 2019
1 parent f6eb3a9 commit db10b1c01fc5bf3fe9f5a3fc031fd9d8a10c3005
Showing with 293 additions and 236 deletions.
  1. +8 −3 src/BlazingComponents/BlazingComponents.csproj
  2. 0 src/BlazingComponents/{TemplatedDialog.cshtml → TemplatedDialog.razor}
  3. 0 src/BlazingComponents/{TemplatedList.cshtml → TemplatedList.razor}
  4. +1 −1 src/BlazingPizza.Client/{App.cshtml → App.razor}
  5. +8 −3 src/BlazingPizza.Client/BlazingPizza.Client.csproj
  6. +24 −23 src/BlazingPizza.Client/Pages/{Index.cshtml → Index.razor}
  7. +6 −5 src/BlazingPizza.Client/Pages/{MyOrders.cshtml → MyOrders.razor}
  8. +0 −106 src/BlazingPizza.Client/Pages/OrderDetails.cshtml
  9. +109 −0 src/BlazingPizza.Client/Pages/OrderDetails.razor
  10. 0 src/BlazingPizza.Client/Pages/{_ViewImports.cshtml → _Imports.razor}
  11. +5 −2 src/BlazingPizza.Client/Shared/{ConfigurePizzaDialog.cshtml → ConfigurePizzaDialog.razor}
  12. 0 src/BlazingPizza.Client/Shared/{ConfiguredPizzaItem.cshtml → ConfiguredPizzaItem.razor}
  13. +1 −1 src/BlazingPizza.Client/Shared/{ForceSignInLayout.cshtml → ForceSignInLayout.razor}
  14. +1 −1 src/BlazingPizza.Client/Shared/{MainLayout.cshtml → MainLayout.razor}
  15. 0 src/BlazingPizza.Client/Shared/{UserInfo.cshtml → UserInfo.razor}
  16. +5 −2 src/BlazingPizza.Client/Startup.cs
  17. +11 −0 src/BlazingPizza.Client/_Imports.razor
  18. +0 −10 src/BlazingPizza.Client/_ViewImports.cshtml
  19. +0 −64 src/BlazingPizza.ComponentsLibrary/Authentication/UserStateProvider.cshtml
  20. +68 −0 src/BlazingPizza.ComponentsLibrary/Authentication/UserStateProvider.razor
  21. +7 −2 src/BlazingPizza.ComponentsLibrary/BlazingPizza.ComponentsLibrary.csproj
  22. 0 src/BlazingPizza.ComponentsLibrary/Map/{Map.cshtml → Map.razor}
  23. +16 −6 src/BlazingPizza.Server/BlazingPizza.Server.csproj
  24. +4 −2 src/BlazingPizza.Server/OrdersController.cs
  25. +4 −0 src/BlazingPizza.Server/Program.cs
  26. +15 −5 src/BlazingPizza.Server/Startup.cs
@@ -1,9 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
<IsPackable>true</IsPackable>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<RazorLangVersion>3.0</RazorLangVersion>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

<ItemGroup>
@@ -13,8 +19,7 @@
<EmbeddedResource Include="content\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview4-19216-03" />
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.
@@ -1,3 +1,3 @@
<UserStateProvider>
<Router AppAssembly=typeof(Program).Assembly />
</UserStateProvider>
</UserStateProvider>
@@ -2,13 +2,18 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Exe</OutputType>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
@@ -56,32 +56,33 @@
</TemplatedDialog>

@functions {
[CascadingParameter] UserStateProvider UserState { get; set; }
[CascadingParameter] UserStateProvider UserState { get; set; }

List<PizzaSpecial> specials;
List<PizzaSpecial> specials;
string BaseUri => UriHelper.GetBaseUri().TrimEnd('/');

protected async override Task OnInitAsync()
{
OrderState.StateChanged += OnOrderStateChanged;
specials = await HttpClient.GetJsonAsync<List<PizzaSpecial>>("/specials");
}
protected async override Task OnInitAsync()
{
OrderState.StateChanged += OnOrderStateChanged;
specials = await HttpClient.GetJsonAsync<List<PizzaSpecial>>($"{BaseUri}/specials");
}

void IDisposable.Dispose()
{
OrderState.StateChanged -= OnOrderStateChanged;
}
void IDisposable.Dispose()
{
OrderState.StateChanged -= OnOrderStateChanged;
}

void OnOrderStateChanged(object sender, EventArgs e) => StateHasChanged();
void OnOrderStateChanged(object sender, EventArgs e) => StateHasChanged();

async Task PlaceOrder()
{
// The server will reject the submission if you're not signed in, so attempt
// to sign in first if needed
if (await UserState.TrySignInAsync())
{
await HttpClient.PostJsonAsync("/orders", OrderState.Order);
OrderState.ResetOrder();
UriHelper.NavigateTo("myorders");
}
}
async Task PlaceOrder()
{
// The server will reject the submission if you're not signed in, so attempt
// to sign in first if needed
if (await UserState.TrySignInAsync())
{
await HttpClient.PostJsonAsync($"{BaseUri}/orders", OrderState.Order);
OrderState.ResetOrder();
UriHelper.NavigateTo("myorders");
}
}
}
@@ -1,5 +1,6 @@
@page "/myorders"
@layout ForceSignInLayout
@inject IUriHelper UriHelper
@inject HttpClient HttpClient

<div class="main">
@@ -30,9 +31,9 @@
</div>

@functions {
async Task<List<OrderWithStatus>> LoadOrders()
{
await Task.Delay(3000);
return await HttpClient.GetJsonAsync<List<OrderWithStatus>>("/orders");
}
string BaseUri => UriHelper.GetBaseUri().TrimEnd('/');
Task<List<OrderWithStatus>> LoadOrders()
{
return HttpClient.GetJsonAsync<List<OrderWithStatus>>($"{BaseUri}/orders");
}
}

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,109 @@
@page "/myorders/{orderId:int}"
@using System.Threading
@layout ForceSignInLayout
@inject IUriHelper UriHelper
@inject HttpClient HttpClient
@implements IDisposable

<div class="main">
@if (invalidOrder)
{
<h2>Nope</h2>
<p>Sorry, this order could not be loaded.</p>
}
else if (orderWithStatus == null)
{
<text>Loading...</text>
}
else
{
<div class="track-order">
<div class="track-order-title">
<h2>
Order placed @orderWithStatus.Order.CreatedTime.ToLongDateString()
</h2>
<p class="ml-auto mb-0">
Status: <strong>@orderWithStatus.StatusText</strong>
</p>
</div>
<div class="track-order-body">
<div class="track-order-details">
@foreach (var pizza in orderWithStatus.Order.Pizzas)
{
<p>
<strong>
@(pizza.Size)"
@pizza.Special.Name
@pizza.GetFormattedTotalPrice())
</strong>
</p>

<ul>
@foreach (var topping in pizza.Toppings)
{
<li>+ @topping.Topping.Name</li>
}
</ul>
}

<p>
<strong>
Total price:
£@orderWithStatus.Order.GetFormattedTotalPrice()
</strong>
</p>
</div>
<div class="track-order-map">
<Map Zoom="13" Markers="@orderWithStatus.MapMarkers" />
</div>
</div>
</div>
}
</div>

@functions {
[Parameter] int OrderId { get; set; }

OrderWithStatus orderWithStatus;
bool invalidOrder;
CancellationTokenSource pollingCancellationToken;

string BaseUri => UriHelper.GetBaseUri().TrimEnd('/');

protected override void OnParametersSet()
{
// If we were already polling for a different order, stop doing so
pollingCancellationToken?.Cancel();

// Start a new poll loop
PollForUpdates();
}

void IDisposable.Dispose()
{
pollingCancellationToken?.Cancel();
}

private async void PollForUpdates()
{
pollingCancellationToken = new CancellationTokenSource();
while (!pollingCancellationToken.IsCancellationRequested)
{
try
{
invalidOrder = false;
orderWithStatus = await HttpClient.GetJsonAsync<OrderWithStatus>($"{BaseUri}/orders/{OrderId}");
}
catch (Exception ex)
{
invalidOrder = true;
pollingCancellationToken.Cancel();
Console.Error.WriteLine(ex);
}

StateHasChanged();

await Task.Delay(4000);
}
}
}
@@ -1,4 +1,5 @@
@inject HttpClient HttpClient
@inject IUriHelper UriHelper
@inject HttpClient HttpClient

<div class="dialog-title">
<h2>@Pizza.Special.Name</h2>
@@ -63,9 +64,11 @@
[Parameter] Action OnCancel { get; set; }
[Parameter] Action OnConfirm { get; set; }

string BaseUri => UriHelper.GetBaseUri().TrimEnd('/');

protected async override Task OnInitAsync()
{
toppings = await HttpClient.GetJsonAsync<List<Topping>>("/toppings");
toppings = await HttpClient.GetJsonAsync<List<Topping>>($"{BaseUri}/toppings");
}

void ToppingSelected(UIChangeEventArgs e)
@@ -1,4 +1,4 @@
@inherits BlazorLayoutComponent
@inherits LayoutComponentBase
@layout MainLayout

@if (UserState.CurrentUser == null) // Retrieving the login state
@@ -1,4 +1,4 @@
@inherits BlazorLayoutComponent
@inherits LayoutComponentBase

<div class="top-bar">
<img class="logo" src="img/logo.svg" />
Oops, something went wrong.

0 comments on commit db10b1c

Please sign in to comment.
You can’t perform that action at this time.