diff --git a/csharp-ms/.gitignore b/csharp-ms/.gitignore index a3325fb..c6c412f 100644 --- a/csharp-ms/.gitignore +++ b/csharp-ms/.gitignore @@ -3,3 +3,5 @@ bin obj packages *.sln.DotSettings.user +# Ignore Blazor wwwroot/lib folder (Bootstrap and other libraries) +**/wwwroot/lib/ diff --git a/csharp-ms/SupermarketReceipt.BlazorApp/Components/App.razor b/csharp-ms/SupermarketReceipt.BlazorApp/Components/App.razor new file mode 100644 index 0000000..9a15697 --- /dev/null +++ b/csharp-ms/SupermarketReceipt.BlazorApp/Components/App.razor @@ -0,0 +1,23 @@ +๏ปฟ + + +
+ + +Current count: @currentCount
+ + + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } +} diff --git a/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Error.razor b/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Error.razor new file mode 100644 index 0000000..576cc2d --- /dev/null +++ b/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Error.razor @@ -0,0 +1,36 @@ +๏ปฟ@page "/Error" +@using System.Diagnostics + +
+ Request ID: @RequestId
+
+ Swapping to Development environment will display more detailed information about the error that occurred. +
++ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +
+ +@code{ + [CascadingParameter] + private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Home.razor b/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Home.razor new file mode 100644 index 0000000..83b675f --- /dev/null +++ b/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Home.razor @@ -0,0 +1,246 @@ +@page "/" +@rendermode InteractiveServer +@inject SupermarketService SupermarketService + +Welcome to the Parrot-themed Supermarket Receipt App!
++ Price: ยฃ@SupermarketService.GetProductPrice(product).ToString("F2") + @if (product.Unit == ProductUnit.Kilo) + { + per kg + } + else + { + each + } +
+Your cart is empty. Add some items! ๐ฆ
+ } +@_receiptText+
Sorry, the content you are looking for does not exist.
\ No newline at end of file diff --git a/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Weather.razor b/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Weather.razor new file mode 100644 index 0000000..f437e5e --- /dev/null +++ b/csharp-ms/SupermarketReceipt.BlazorApp/Components/Pages/Weather.razor @@ -0,0 +1,64 @@ +๏ปฟ@page "/weather" +@attribute [StreamRendering] + +This component demonstrates showing data.
+ +@if (forecasts == null) +{ +Loading...
+} +else +{ +| Date | +Temp. (C) | +Temp. (F) | +Summary | +
|---|---|---|---|
| @forecast.Date.ToShortDateString() | +@forecast.TemperatureC | +@forecast.TemperatureF | +@forecast.Summary | +