Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions AspNetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Compon
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter", "src\Components\QuickGrid\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter\src\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter.csproj", "{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazingPizza.Server", "src\Components\benchmarkapps\BlazingPizza.Server\BlazingPizza.Server.csproj", "{A05652B3-953E-4915-9D7F-0E361D988815}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Endpoints", "Endpoints", "{7BAEB9BF-28F4-4DFD-9A04-E5193683C261}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.Endpoints", "src\Components\Endpoints\src\Microsoft.AspNetCore.Components.Endpoints.csproj", "{AE4D272D-6F13-42C8-9404-C149188AFA33}"
Expand Down Expand Up @@ -10635,6 +10637,22 @@ Global
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x64.Build.0 = Release|Any CPU
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x86.ActiveCfg = Release|Any CPU
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x86.Build.0 = Release|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Debug|arm64.ActiveCfg = Debug|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Debug|arm64.Build.0 = Debug|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Debug|x64.ActiveCfg = Debug|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Debug|x64.Build.0 = Debug|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Debug|x86.ActiveCfg = Debug|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Debug|x86.Build.0 = Debug|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Release|Any CPU.Build.0 = Release|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Release|arm64.ActiveCfg = Release|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Release|arm64.Build.0 = Release|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Release|x64.ActiveCfg = Release|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Release|x64.Build.0 = Release|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Release|x86.ActiveCfg = Release|Any CPU
{A05652B3-953E-4915-9D7F-0E361D988815}.Release|x86.Build.0 = Release|Any CPU
{AE4D272D-6F13-42C8-9404-C149188AFA33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE4D272D-6F13-42C8-9404-C149188AFA33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE4D272D-6F13-42C8-9404-C149188AFA33}.Debug|arm64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -11557,6 +11575,7 @@ Global
{C406D9E0-1585-43F9-AA8F-D468AF84A996} = {60D51C98-2CC0-40DF-B338-44154EFEE2FF}
{7757E360-40F5-4C90-9D7F-E6B0E62BA9E2} = {C406D9E0-1585-43F9-AA8F-D468AF84A996}
{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931} = {C406D9E0-1585-43F9-AA8F-D468AF84A996}
{A05652B3-953E-4915-9D7F-0E361D988815} = {0CE1CC26-98CE-4022-A81C-E32AAFC9B819}
{7BAEB9BF-28F4-4DFD-9A04-E5193683C261} = {60D51C98-2CC0-40DF-B338-44154EFEE2FF}
{AE4D272D-6F13-42C8-9404-C149188AFA33} = {7BAEB9BF-28F4-4DFD-9A04-E5193683C261}
{5D438258-CB19-4282-814F-974ABBC71411} = {7BAEB9BF-28F4-4DFD-9A04-E5193683C261}
Expand Down
1 change: 1 addition & 0 deletions src/Components/Components.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"src\\Components\\WebView\\WebView\\test\\Microsoft.AspNetCore.Components.WebView.Test.csproj",
"src\\Components\\Web\\src\\Microsoft.AspNetCore.Components.Web.csproj",
"src\\Components\\Web\\test\\Microsoft.AspNetCore.Components.Web.Tests.csproj",
"src\\Components\\benchmarkapps\\BlazingPizza.Server\\BlazingPizza.Server.csproj",
"src\\Components\\benchmarkapps\\Wasm.Performance\\Driver\\Wasm.Performance.Driver.csproj",
"src\\Components\\benchmarkapps\\Wasm.Performance\\TestApp\\Wasm.Performance.TestApp.csproj",
"src\\Components\\test\\E2ETest\\Microsoft.AspNetCore.Components.E2ETests.csproj",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<IsTestAssetProject>true</IsTestAssetProject>
<NoWarn>$(NoWarn);IDE0161;IDE0073</NoWarn>
</PropertyGroup>

<ItemGroup>
<Reference Include="Microsoft.AspNetCore" />
<Reference Include="Microsoft.AspNetCore.Components.Server" />
<Reference Include="Microsoft.AspNetCore.HttpsPolicy" />
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.Extensions.Hosting" />
</ItemGroup>

</Project>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Microsoft.JSInterop;
using System.Threading.Tasks;
using Microsoft.JSInterop;

namespace BlazingPizza.Server
namespace BlazingPizza.Server;

public static class JSRuntimeExtensions
{
public static class JSRuntimeExtensions
public static ValueTask<bool> Confirm(this IJSRuntime jsRuntime, string message)
{
public static ValueTask<bool> Confirm(this IJSRuntime jsRuntime, string message)
{
return jsRuntime.InvokeAsync<bool>("confirm", message);
}
return jsRuntime.InvokeAsync<bool>("confirm", message);
}
}
35 changes: 17 additions & 18 deletions src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;

namespace BlazingPizza
namespace BlazingPizza.Server.Model;

public class Address
{
public class Address
{
public int Id { get; set; }
public int Id { get; set; }

[Required, MaxLength(100)]
public string Name { get; set; }
[Required, MaxLength(100)]
public string Name { get; set; }

[Required, MaxLength(100)]
public string Line1 { get; set; }
[Required, MaxLength(100)]
public string Line1 { get; set; }

[MaxLength(100)]
public string Line2 { get; set; }
[MaxLength(100)]
public string Line2 { get; set; }

[Required, MaxLength(50)]
public string City { get; set; }
[Required, MaxLength(50)]
public string City { get; set; }

[Required, MaxLength(20)]
public string Region { get; set; }
[Required, MaxLength(20)]
public string Region { get; set; }

[Required, MaxLength(20)]
public string PostalCode { get; set; }
}
[Required, MaxLength(20)]
public string PostalCode { get; set; }
}
37 changes: 18 additions & 19 deletions src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
namespace BlazingPizza
namespace BlazingPizza.Server.Model;

public class LatLong
{
public class LatLong
public LatLong()
{
public LatLong()
{
}
}

public LatLong(double latitude, double longitude) : this()
{
Latitude = latitude;
Longitude = longitude;
}
public LatLong(double latitude, double longitude) : this()
{
Latitude = latitude;
Longitude = longitude;
}

public double Latitude { get; set; }
public double Latitude { get; set; }

public double Longitude { get; set; }
public double Longitude { get; set; }

public static LatLong Interpolate(LatLong start, LatLong end, double proportion)
{
// The Earth is flat, right? So no need for spherical interpolation.
return new LatLong(
start.Latitude + (end.Latitude - start.Latitude) * proportion,
start.Longitude + (end.Longitude - start.Longitude) * proportion);
}
public static LatLong Interpolate(LatLong start, LatLong end, double proportion)
{
// The Earth is flat, right? So no need for spherical interpolation.
return new LatLong(
start.Latitude + (end.Latitude - start.Latitude) * proportion,
start.Longitude + (end.Longitude - start.Longitude) * proportion);
}
}
27 changes: 12 additions & 15 deletions src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;

namespace BlazingPizza
namespace BlazingPizza.Server.Model;

public class Order
{
public class Order
{
public int OrderId { get; set; }
public int OrderId { get; set; }

public string UserId { get; set; }
public string UserId { get; set; }

public DateTime CreatedTime { get; set; }
public DateTime CreatedTime { get; set; }

public Address DeliveryAddress { get; set; } = new Address();
public Address DeliveryAddress { get; set; } = new Address();

public LatLong DeliveryLocation { get; set; }
public LatLong DeliveryLocation { get; set; }

public List<Pizza> Pizzas { get; set; } = new List<Pizza>();
public List<Pizza> Pizzas { get; set; } = new List<Pizza>();

public decimal GetTotalPrice() => Pizzas.Sum(p => p.GetTotalPrice());
public decimal GetTotalPrice() => Pizzas.Sum(p => p.GetTotalPrice());

public string GetFormattedTotalPrice() => GetTotalPrice().ToString("0.00");
}
public string GetFormattedTotalPrice() => GetTotalPrice().ToString("0.00", CultureInfo.CurrentCulture);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
namespace BlazingPizza.Server.Model;

public class OrderState
{
private readonly ILogger<OrderState> logger;

public OrderState(ILogger<OrderState> logger)
{
this.logger = logger;
}

public bool ShowingConfigureDialog { get; private set; }

public Pizza ConfiguringPizza { get; private set; }

public Order Order { get; private set; } = new Order();

public void ShowConfigurePizzaDialog(PizzaSpecial special)
{
logger.LogInformation($"Configuring pizza {special.Id}");

ConfiguringPizza = new Pizza()
{
Special = special,
SpecialId = special.Id,
Size = Pizza.DefaultSize,
Toppings = new List<PizzaTopping>(),
};

ShowingConfigureDialog = true;
}

public void CancelConfigurePizzaDialog()
{
ConfiguringPizza = null;

ShowingConfigureDialog = false;
}

public void ConfirmConfigurePizzaDialog()
{
logger.LogInformation($"Adding pizza {ConfiguringPizza.SpecialId}");

Order.Pizzas.Add(ConfiguringPizza);
ConfiguringPizza = null;

ShowingConfigureDialog = false;
}

public void RemoveConfiguredPizza(Pizza pizza)
{
Order.Pizzas.Remove(pizza);
}

public void ResetOrder()
{
Order = new Order();
}

public void ReplaceOrder(Order order)
{
Order = order;
}
}
56 changes: 27 additions & 29 deletions src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
using System.Collections.Generic;
using System.Linq;
using System.Globalization;

namespace BlazingPizza
namespace BlazingPizza.Server.Model;

/// <summary>
/// Represents a customized pizza as part of an order
/// </summary>
public class Pizza
{
/// <summary>
/// Represents a customized pizza as part of an order
/// </summary>
public class Pizza
{
public const int DefaultSize = 12;
public const int MinimumSize = 9;
public const int MaximumSize = 17;
public const int DefaultSize = 12;
public const int MinimumSize = 9;
public const int MaximumSize = 17;

public int Id { get; set; }
public int Id { get; set; }

public int OrderId { get; set; }
public int OrderId { get; set; }

public PizzaSpecial Special { get; set; }
public PizzaSpecial Special { get; set; }

public int SpecialId { get; set; }
public int SpecialId { get; set; }

public int Size { get; set; }
public int Size { get; set; }

public List<PizzaTopping> Toppings { get; set; }
public List<PizzaTopping> Toppings { get; set; }

public decimal GetBasePrice()
{
return ((decimal)Size / (decimal)DefaultSize) * Special.BasePrice;
}
public decimal GetBasePrice()
{
return Special.BasePrice * (decimal)Size / DefaultSize;
}

public decimal GetTotalPrice()
{
return GetBasePrice() + Toppings.Sum(t => t.Topping.Price);
}
public decimal GetTotalPrice()
{
return GetBasePrice() + Toppings.Sum(t => t.Topping.Price);
}

public string GetFormattedTotalPrice()
{
return GetTotalPrice().ToString("0.00");
}
public string GetFormattedTotalPrice()
{
return GetTotalPrice().ToString("0.00", CultureInfo.CurrentCulture);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
namespace BlazingPizza
using System.Globalization;

namespace BlazingPizza.Server.Model;

/// <summary>
/// Represents a pre-configured template for a pizza a user can order
/// </summary>
public class PizzaSpecial
{
/// <summary>
/// Represents a pre-configured template for a pizza a user can order
/// </summary>
public class PizzaSpecial
{
public int Id { get; set; }
public int Id { get; set; }

public string Name { get; set; }
public string Name { get; set; }

public int BasePrice { get; set; }
public int BasePrice { get; set; }

public string Description { get; set; }
public string Description { get; set; }

public string ImageUrl { get; set; }
public string ImageUrl { get; set; }

public string GetFormattedBasePrice() => BasePrice.ToString("0.00");
}
public string GetFormattedBasePrice() => BasePrice.ToString("0.00", CultureInfo.CurrentCulture);
}
Loading