diff --git a/.github/workflows/BlazingServerTrains.yml b/.github/workflows/BlazingServerTrains.yml new file mode 100644 index 00000000..f64491aa --- /dev/null +++ b/.github/workflows/BlazingServerTrains.yml @@ -0,0 +1,35 @@ +name: Build and deploy .NET Core application to Web App BlazingServerTrains +env: + AZURE_WEBAPP_NAME: BlazingServerTrains + AZURE_WEBAPP_PACKAGE_PATH: src\BlazingServerTrains\published + CONFIGURATION: Release + DOTNET_CORE_VERSION: 6.0.x + WORKING_DIRECTORY: src\BlazingServerTrains +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.DOTNET_CORE_VERSION }} + - name: Restore + run: dotnet restore "${{ env.WORKING_DIRECTORY }}" + - name: Build + run: dotnet build "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore + - name: Test + run: dotnet test "${{ env.WORKING_DIRECTORY }}" --no-build + - name: Publish + run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}" + - name: Deploy to Azure WebApp + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.BLAZINGSERVERTRAINS_FFFF }} + package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} + - name: Publish Artifacts + uses: actions/upload-artifact@v1.0.0 + with: + name: webapp + path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} diff --git a/Trains.NET.sln b/Trains.NET.sln index 257f15c8..81ce80f0 100644 --- a/Trains.NET.sln +++ b/Trains.NET.sln @@ -45,6 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinTrains", "src\WinTrains\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazingTrains", "src\BlazingTrains\BlazingTrains.csproj", "{79D851AC-3713-4582-A20A-5E6C24FEAE6B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazingServerTrains", "src\BlazingServerTrains\BlazingServerTrains.csproj", "{EAECA630-1A76-476F-B6B9-66ADB1BBFF28}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -95,6 +97,10 @@ Global {79D851AC-3713-4582-A20A-5E6C24FEAE6B}.Debug|Any CPU.Build.0 = Debug|Any CPU {79D851AC-3713-4582-A20A-5E6C24FEAE6B}.Release|Any CPU.ActiveCfg = Release|Any CPU {79D851AC-3713-4582-A20A-5E6C24FEAE6B}.Release|Any CPU.Build.0 = Release|Any CPU + {EAECA630-1A76-476F-B6B9-66ADB1BBFF28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EAECA630-1A76-476F-B6B9-66ADB1BBFF28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EAECA630-1A76-476F-B6B9-66ADB1BBFF28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EAECA630-1A76-476F-B6B9-66ADB1BBFF28}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -111,6 +117,7 @@ Global {10E5BE95-85C2-456C-A32B-A77E7EB702A1} = {6D7A257F-24F9-43A2-870A-14DFCA32DDD2} {894082D5-C407-476F-9EAA-B412411E6E1F} = {77E57704-D3D8-4228-A195-1F90FD62539A} {79D851AC-3713-4582-A20A-5E6C24FEAE6B} = {77E57704-D3D8-4228-A195-1F90FD62539A} + {EAECA630-1A76-476F-B6B9-66ADB1BBFF28} = {77E57704-D3D8-4228-A195-1F90FD62539A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8834C621-39E4-4AD6-85D0-97F46ADC88D6} diff --git a/src/BlazingServerTrains/App.razor b/src/BlazingServerTrains/App.razor new file mode 100644 index 00000000..6fd3ed1b --- /dev/null +++ b/src/BlazingServerTrains/App.razor @@ -0,0 +1,12 @@ + + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/src/BlazingServerTrains/BlazingServerTrains.csproj b/src/BlazingServerTrains/BlazingServerTrains.csproj new file mode 100644 index 00000000..acc67662 --- /dev/null +++ b/src/BlazingServerTrains/BlazingServerTrains.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + diff --git a/src/BlazingServerTrains/Data/SharedObject.cs b/src/BlazingServerTrains/Data/SharedObject.cs new file mode 100644 index 00000000..c33dcdcd --- /dev/null +++ b/src/BlazingServerTrains/Data/SharedObject.cs @@ -0,0 +1,26 @@ +using System.Collections.ObjectModel; +using System.ComponentModel; +using MvvmHelpers; + +namespace BlazingServerTrains.Data; + +public class SharedObject : ObservableObject +{ + //public event PropertyChangedEventHandler? PropertyChanged; + //public + //public string Key { get; init; } + //public string Value + //{ + // get + // { + // return Items.FirstOrDefault(x => x.key == this.Key)?.value; + // } + // set + // { + // if(Items.Contains() + // } + //} + + //public static Con<(string key, string value)> Items = new(); + +} diff --git a/src/BlazingServerTrains/Data/WeatherForecast.cs b/src/BlazingServerTrains/Data/WeatherForecast.cs new file mode 100644 index 00000000..cfc1e5b3 --- /dev/null +++ b/src/BlazingServerTrains/Data/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace BlazingServerTrains.Data +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} \ No newline at end of file diff --git a/src/BlazingServerTrains/Data/WeatherForecastService.cs b/src/BlazingServerTrains/Data/WeatherForecastService.cs new file mode 100644 index 00000000..8ed91764 --- /dev/null +++ b/src/BlazingServerTrains/Data/WeatherForecastService.cs @@ -0,0 +1,20 @@ +namespace BlazingServerTrains.Data +{ + public class WeatherForecastService + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + public Task GetForecastAsync(DateTime startDate) + { + return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = startDate.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }).ToArray()); + } + } +} \ No newline at end of file diff --git a/src/BlazingServerTrains/Pages/Counter.razor b/src/BlazingServerTrains/Pages/Counter.razor new file mode 100644 index 00000000..abd5fda5 --- /dev/null +++ b/src/BlazingServerTrains/Pages/Counter.razor @@ -0,0 +1,18 @@ +@page "/counter" + +Counter + +

Counter

+ +

Current count: @currentCount

+ + + +@code { + private static int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } +} diff --git a/src/BlazingServerTrains/Pages/Error.cshtml b/src/BlazingServerTrains/Pages/Error.cshtml new file mode 100644 index 00000000..9bdd6475 --- /dev/null +++ b/src/BlazingServerTrains/Pages/Error.cshtml @@ -0,0 +1,42 @@ +@page +@model BlazingServerTrains.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

+ + @if (Model.ShowRequestId) + { +

+ Request ID: @Model.RequestId +

+ } + +

Development Mode

+

+ Swapping to the Development environment displays 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. +

+
+
+ + + diff --git a/src/BlazingServerTrains/Pages/Error.cshtml.cs b/src/BlazingServerTrains/Pages/Error.cshtml.cs new file mode 100644 index 00000000..e5e6ae1a --- /dev/null +++ b/src/BlazingServerTrains/Pages/Error.cshtml.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Diagnostics; + +namespace BlazingServerTrains.Pages +{ + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [IgnoreAntiforgeryToken] + public class ErrorModel : PageModel + { + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} \ No newline at end of file diff --git a/src/BlazingServerTrains/Pages/FetchData.razor b/src/BlazingServerTrains/Pages/FetchData.razor new file mode 100644 index 00000000..edcfc6dc --- /dev/null +++ b/src/BlazingServerTrains/Pages/FetchData.razor @@ -0,0 +1,21 @@ +@page "/fetchdata" + +Weather forecast + +@using BlazingServerTrains.Data +@inject WeatherForecastService ForecastService + +

Weather forecast

+ +

This component demonstrates fetching data from a service.

+