diff --git a/AspNetCore.sln b/AspNetCore.sln index c42907f8a698..262e42e929ed 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -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}" @@ -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 @@ -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} diff --git a/src/Components/Components.slnf b/src/Components/Components.slnf index e5f8cdf734d7..4a76be3f2453 100644 --- a/src/Components/Components.slnf +++ b/src/Components/Components.slnf @@ -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", diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/BlazingPizza.Server.csproj b/src/Components/benchmarkapps/BlazingPizza.Server/BlazingPizza.Server.csproj index 08d32e924989..0a92ed6f8863 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/BlazingPizza.Server.csproj +++ b/src/Components/benchmarkapps/BlazingPizza.Server/BlazingPizza.Server.csproj @@ -1,6 +1,17 @@  + $(DefaultNetCoreTargetFramework) true + $(NoWarn);IDE0161;IDE0073 + + + + + + + + + diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.props b/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.props deleted file mode 100644 index 8c119d5413b5..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.props +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.targets b/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.targets deleted file mode 100644 index 2e3fb2fa7134..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/JSRuntimeExtensions.cs b/src/Components/benchmarkapps/BlazingPizza.Server/JSRuntimeExtensions.cs index d17523aca123..6494cff9542c 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/JSRuntimeExtensions.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/JSRuntimeExtensions.cs @@ -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 Confirm(this IJSRuntime jsRuntime, string message) { - public static ValueTask Confirm(this IJSRuntime jsRuntime, string message) - { - return jsRuntime.InvokeAsync("confirm", message); - } + return jsRuntime.InvokeAsync("confirm", message); } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs index d76bc52a8142..dfc8263f413e 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs @@ -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; } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs index 9b8c38113973..23e281d28438 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs @@ -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); } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs index fb003bd6df07..3339187c35d2 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs @@ -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 Pizzas { get; set; } = new List(); + public List Pizzas { get; set; } = new List(); - 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); } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/OrderState.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/OrderState.cs new file mode 100644 index 000000000000..f95dd052fe2f --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/OrderState.cs @@ -0,0 +1,64 @@ +namespace BlazingPizza.Server.Model; + +public class OrderState +{ + private readonly ILogger logger; + + public OrderState(ILogger 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(), + }; + + 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; + } +} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs index ec1108a98d1d..caba0152e955 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs @@ -1,42 +1,40 @@ -using System.Collections.Generic; -using System.Linq; +using System.Globalization; -namespace BlazingPizza +namespace BlazingPizza.Server.Model; + +/// +/// Represents a customized pizza as part of an order +/// +public class Pizza { - /// - /// Represents a customized pizza as part of an order - /// - 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 Toppings { get; set; } + public List 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); } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaSpecial.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaSpecial.cs index d94b00be2dec..884ac27236e4 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaSpecial.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaSpecial.cs @@ -1,20 +1,21 @@ -namespace BlazingPizza +using System.Globalization; + +namespace BlazingPizza.Server.Model; + +/// +/// Represents a pre-configured template for a pizza a user can order +/// +public class PizzaSpecial { - /// - /// Represents a pre-configured template for a pizza a user can order - /// - 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); } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaTopping.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaTopping.cs index f5a6c1acdfa5..d8d861912cab 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaTopping.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaTopping.cs @@ -1,11 +1,10 @@ -namespace BlazingPizza +namespace BlazingPizza.Server.Model; + +public class PizzaTopping { - public class PizzaTopping - { - public Topping Topping { get; set; } + public Topping Topping { get; set; } - public int ToppingId { get; set; } - - public int PizzaId { get; set; } - } + public int ToppingId { get; set; } + + public int PizzaId { get; set; } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Point.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Point.cs index 6c8a611ccbf9..5896d8b6737f 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Point.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Point.cs @@ -1,9 +1,8 @@ -namespace BlazingPizza.Server +namespace BlazingPizza.Server.Model; + +public class Point { - public class Point - { - public double X { get; set; } + public double X { get; set; } - public double Y { get; set; } - } + public double Y { get; set; } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/SpecialsService.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/SpecialsService.cs new file mode 100644 index 000000000000..d4c37cd1d33d --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/SpecialsService.cs @@ -0,0 +1,74 @@ +namespace BlazingPizza.Server.Model; + +public class SpecialsService +{ + public IList GetSpecials() + { + return new PizzaSpecial[] + { + new PizzaSpecial() + { + Name = "Basic Cheese Pizza", + Description = "It's cheesy and delicious. Why wouldn't you want one?", + BasePrice = 9, + ImageUrl = "img/pizzas/cheese.jpg", + }, + new PizzaSpecial() + { + Id = 2, + Name = "The Baconatorizor", + Description = "It has EVERY kind of bacon", + BasePrice = 12, + ImageUrl = "img/pizzas/bacon.jpg", + }, + new PizzaSpecial() + { + Id = 3, + Name = "Classic pepperoni", + Description = "It's the pizza you grew up with, but Blazing hot!", + BasePrice = 10, + ImageUrl = "img/pizzas/pepperoni.jpg", + }, + new PizzaSpecial() + { + Id = 4, + Name = "Buffalo chicken", + Description = "Spicy chicken, hot sauce and bleu cheese, guaranteed to warm you up", + BasePrice = 12, + ImageUrl = "img/pizzas/meaty.jpg", + }, + new PizzaSpecial() + { + Id = 5, + Name = "Mushroom Lovers", + Description = "It has mushrooms. Isn't that obvious?", + BasePrice = 11, + ImageUrl = "img/pizzas/mushroom.jpg", + }, + new PizzaSpecial() + { + Id = 6, + Name = "The Brit", + Description = "When in London...", + BasePrice = 10, + ImageUrl = "img/pizzas/brit.jpg", + }, + new PizzaSpecial() + { + Id = 7, + Name = "Veggie Delight", + Description = "It's like salad, but on a pizza", + BasePrice = 11, + ImageUrl = "img/pizzas/salad.jpg", + }, + new PizzaSpecial() + { + Id = 8, + Name = "Margherita", + Description = "Traditional Italian pizza with tomatoes and basil", + BasePrice = 9, + ImageUrl = "img/pizzas/margherita.jpg", + }, + }; + } +} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Topping.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Topping.cs index 61bdeb92000c..cbf90b3b88b7 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Topping.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Topping.cs @@ -1,13 +1,14 @@ -namespace BlazingPizza +using System.Globalization; + +namespace BlazingPizza.Server.Model; + +public class Topping { - public class Topping - { - public int Id { get; set; } + public int Id { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public decimal Price { get; set; } + public decimal Price { get; set; } - public string GetFormattedPrice() => Price.ToString("0.00"); - } + public string GetFormattedPrice() => Price.ToString("0.00", CultureInfo.CurrentCulture); } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/ToppingsService.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/ToppingsService.cs new file mode 100644 index 000000000000..1ba0f8989e1c --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/ToppingsService.cs @@ -0,0 +1,121 @@ +namespace BlazingPizza.Server.Model; + +public class ToppingsService +{ + public IList GetToppings() + { + return new Topping[] + { + new Topping() + { + Name = "Extra cheese", + Price = 2.50m, + }, + new Topping() + { + Name = "American bacon", + Price = 2.99m, + }, + new Topping() + { + Name = "British bacon", + Price = 2.99m, + }, + new Topping() + { + Name = "Canadian bacon", + Price = 2.99m, + }, + new Topping() + { + Name = "Tea and crumpets", + Price = 5.00m + }, + new Topping() + { + Name = "Fresh-baked scones", + Price = 4.50m, + }, + new Topping() + { + Name = "Bell peppers", + Price = 1.00m, + }, + new Topping() + { + Name = "Onions", + Price = 1.00m, + }, + new Topping() + { + Name = "Mushrooms", + Price = 1.00m, + }, + new Topping() + { + Name = "Pepperoni", + Price = 1.00m, + }, + new Topping() + { + Name = "Duck sausage", + Price = 3.20m, + }, + new Topping() + { + Name = "Venison meatballs", + Price = 2.50m, + }, + new Topping() + { + Name = "Served on a silver platter", + Price = 250.99m, + }, + new Topping() + { + Name = "Lobster on top", + Price = 64.50m, + }, + new Topping() + { + Name = "Sturgeon caviar", + Price = 101.75m, + }, + new Topping() + { + Name = "Artichoke hearts", + Price = 3.40m, + }, + new Topping() + { + Name = "Fresh tomatoes", + Price = 1.50m, + }, + new Topping() + { + Name = "Basil", + Price = 1.50m, + }, + new Topping() + { + Name = "Steak (medium-rare)", + Price = 8.50m, + }, + new Topping() + { + Name = "Blazing hot peppers", + Price = 4.20m, + }, + new Topping() + { + Name = "Buffalo chicken", + Price = 5.00m, + }, + new Topping() + { + Name = "Blue cheese", + Price = 2.50m, + }, + }; + } +} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/UserInfo.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/UserInfo.cs deleted file mode 100644 index 4996ef8042ae..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/UserInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace BlazingPizza -{ - public class UserInfo - { - public bool IsAuthenticated { get; set; } - - public string Name { get; set; } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/NuGet.config b/src/Components/benchmarkapps/BlazingPizza.Server/NuGet.config deleted file mode 100644 index 2739120bf214..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/OrderState.cs b/src/Components/benchmarkapps/BlazingPizza.Server/OrderState.cs deleted file mode 100644 index 5e150303fc54..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/OrderState.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections.Generic; -using Microsoft.Extensions.Logging; - -namespace BlazingPizza.Server -{ - public class OrderState - { - private readonly ILogger logger; - - public OrderState(ILogger 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(), - }; - - 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; - } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Checkout.razor b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Checkout.razor index e41d5dd20474..ab1c71e3887f 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Checkout.razor +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Checkout.razor @@ -27,8 +27,6 @@ protected override void OnInitialized() { // Try to recover any temporary saved order - OrderState.ReplaceOrder(new Order - { - }); + OrderState.ReplaceOrder(new Order()); } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Index.razor b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Index.razor index 36d14e6faa9e..8d24d73b3c3d 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Index.razor +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Index.razor @@ -3,6 +3,8 @@ @inject IJSRuntime JS @inject SpecialsService Specials +Blazing Pizza: Home +
    @if (specials != null) diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml index 07214adc9ed1..a5d41cd5a08e 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml @@ -1,22 +1,20 @@ @page "/" +@using BlazingPizza.Server +@using Microsoft.AspNetCore.Components.Web +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - BlazorServerSIde - - + + + - @(await Html.RenderComponentAsync(RenderMode.ServerPrerendered)) - - + + diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Program.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Program.cs index 02b01004147f..5ca83f31f635 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Program.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Program.cs @@ -1,23 +1,31 @@ -using System; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; +using BlazingPizza.Server; +using BlazingPizza.Server.Model; -namespace BlazingPizza.Server +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddRazorPages(); +builder.Services.AddServerSideBlazor(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) { - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } + app.UseExceptionHandler("/Error"); + app.UseHsts(); } + +app.UseHttpsRedirection(); + +app.UseStaticFiles(); + +app.UseRouting(); + +app.MapBlazorHub(); +app.MapFallbackToPage("/_Host"); + +app.Run(); diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Properties/launchSettings.json b/src/Components/benchmarkapps/BlazingPizza.Server/Properties/launchSettings.json new file mode 100644 index 000000000000..91d7c0f2788d --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "BlazingPizza.Server": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:61128;http://localhost:61129" + } + } +} \ No newline at end of file diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor b/src/Components/benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor index 8e4cc24cf8b8..158863a3a30f 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor @@ -1,5 +1,7 @@ @inherits LayoutComponentBase +Blazing Pizza +
    diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/SpecialsService.cs b/src/Components/benchmarkapps/BlazingPizza.Server/SpecialsService.cs deleted file mode 100644 index 6e36dd222297..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/SpecialsService.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Collections.Generic; - -namespace BlazingPizza.Server -{ - public class SpecialsService - { - public IList GetSpecials() - { - return new PizzaSpecial[] - { - new PizzaSpecial() - { - Name = "Basic Cheese Pizza", - Description = "It's cheesy and delicious. Why wouldn't you want one?", - BasePrice = 9, - ImageUrl = "img/pizzas/cheese.jpg", - }, - new PizzaSpecial() - { - Id = 2, - Name = "The Baconatorizor", - Description = "It has EVERY kind of bacon", - BasePrice = 12, - ImageUrl = "img/pizzas/bacon.jpg", - }, - new PizzaSpecial() - { - Id = 3, - Name = "Classic pepperoni", - Description = "It's the pizza you grew up with, but Blazing hot!", - BasePrice = 10, - ImageUrl = "img/pizzas/pepperoni.jpg", - }, - new PizzaSpecial() - { - Id = 4, - Name = "Buffalo chicken", - Description = "Spicy chicken, hot sauce and bleu cheese, guaranteed to warm you up", - BasePrice = 12, - ImageUrl = "img/pizzas/meaty.jpg", - }, - new PizzaSpecial() - { - Id = 5, - Name = "Mushroom Lovers", - Description = "It has mushrooms. Isn't that obvious?", - BasePrice = 11, - ImageUrl = "img/pizzas/mushroom.jpg", - }, - new PizzaSpecial() - { - Id = 6, - Name = "The Brit", - Description = "When in London...", - BasePrice = 10, - ImageUrl = "img/pizzas/brit.jpg", - }, - new PizzaSpecial() - { - Id = 7, - Name = "Veggie Delight", - Description = "It's like salad, but on a pizza", - BasePrice = 11, - ImageUrl = "img/pizzas/salad.jpg", - }, - new PizzaSpecial() - { - Id = 8, - Name = "Margherita", - Description = "Traditional Italian pizza with tomatoes and basil", - BasePrice = 9, - ImageUrl = "img/pizzas/margherita.jpg", - }, - }; - } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Startup.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Startup.cs deleted file mode 100644 index 73fb78931ec9..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Startup.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.ResponseCompression; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using System.Linq; -using System.Net.Mime; - -namespace BlazingPizza.Server -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - public void ConfigureServices(IServiceCollection services) - { - services.AddMvc(); - - services.AddServerSideBlazor(options => options.DetailedErrors = true); - - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - services.AddResponseCompression(options => - { - options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat( - new[] { MediaTypeNames.Application.Octet }); - }); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.UseResponseCompression(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseStaticFiles(); - - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - endpoints.MapBlazorHub(); - endpoints.MapFallbackToPage("/_Host"); - }); - } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs b/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs deleted file mode 100644 index 07c80c9790f4..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System.Collections.Generic; - -namespace BlazingPizza.Server -{ - public class ToppingsService - { - public IList GetToppings() - { - return new Topping[] - { - new Topping() - { - Name = "Extra cheese", - Price = 2.50m, - }, - new Topping() - { - Name = "American bacon", - Price = 2.99m, - }, - new Topping() - { - Name = "British bacon", - Price = 2.99m, - }, - new Topping() - { - Name = "Canadian bacon", - Price = 2.99m, - }, - new Topping() - { - Name = "Tea and crumpets", - Price = 5.00m - }, - new Topping() - { - Name = "Fresh-baked scones", - Price = 4.50m, - }, - new Topping() - { - Name = "Bell peppers", - Price = 1.00m, - }, - new Topping() - { - Name = "Onions", - Price = 1.00m, - }, - new Topping() - { - Name = "Mushrooms", - Price = 1.00m, - }, - new Topping() - { - Name = "Pepperoni", - Price = 1.00m, - }, - new Topping() - { - Name = "Duck sausage", - Price = 3.20m, - }, - new Topping() - { - Name = "Venison meatballs", - Price = 2.50m, - }, - new Topping() - { - Name = "Served on a silver platter", - Price = 250.99m, - }, - new Topping() - { - Name = "Lobster on top", - Price = 64.50m, - }, - new Topping() - { - Name = "Sturgeon caviar", - Price = 101.75m, - }, - new Topping() - { - Name = "Artichoke hearts", - Price = 3.40m, - }, - new Topping() - { - Name = "Fresh tomatoes", - Price = 1.50m, - }, - new Topping() - { - Name = "Basil", - Price = 1.50m, - }, - new Topping() - { - Name = "Steak (medium-rare)", - Price = 8.50m, - }, - new Topping() - { - Name = "Blazing hot peppers", - Price = 4.20m, - }, - new Topping() - { - Name = "Buffalo chicken", - Price = 5.00m, - }, - new Topping() - { - Name = "Blue cheese", - Price = 2.50m, - }, - }; - } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/_Imports.razor b/src/Components/benchmarkapps/BlazingPizza.Server/_Imports.razor index f9e4f6730d74..32f6809bb2e4 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/_Imports.razor +++ b/src/Components/benchmarkapps/BlazingPizza.Server/_Imports.razor @@ -5,5 +5,6 @@ @using Microsoft.AspNetCore.Components.Web @using Microsoft.JSInterop @using BlazingPizza.Server +@using BlazingPizza.Server.Model @using BlazingPizza.Server.Shared @using System.Security.Claims