diff --git a/App.razor b/App.razor index bf6c773..6fd3ed1 100644 --- a/App.razor +++ b/App.razor @@ -1,11 +1,12 @@ - - + + + Not found -

Sorry, there's nothing at this address.

+

Sorry, there's nothing at this address.

diff --git a/CreatingTimePickerSample.csproj b/CreatingTimePickerSample.csproj new file mode 100644 index 0000000..cdecf84 --- /dev/null +++ b/CreatingTimePickerSample.csproj @@ -0,0 +1,14 @@ + + + + net7.0 + enable + enable + + + + + + + + diff --git a/TimePickerProject.sln b/CreatingTimePickerSample.sln similarity index 52% rename from TimePickerProject.sln rename to CreatingTimePickerSample.sln index 5006cf6..efd2b9a 100644 --- a/TimePickerProject.sln +++ b/CreatingTimePickerSample.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29424.173 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimePickerProject", "TimePickerProject.csproj", "{8C4E0C25-0ACB-4773-92EB-420836797DC6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreatingTimePickerSample", "CreatingTimePickerSample.csproj", "{23D87206-15A2-4D42-B2A7-8E74827D8C45}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8C4E0C25-0ACB-4773-92EB-420836797DC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8C4E0C25-0ACB-4773-92EB-420836797DC6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8C4E0C25-0ACB-4773-92EB-420836797DC6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8C4E0C25-0ACB-4773-92EB-420836797DC6}.Release|Any CPU.Build.0 = Release|Any CPU + {23D87206-15A2-4D42-B2A7-8E74827D8C45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23D87206-15A2-4D42-B2A7-8E74827D8C45}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23D87206-15A2-4D42-B2A7-8E74827D8C45}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23D87206-15A2-4D42-B2A7-8E74827D8C45}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {45098D05-6EBB-43F7-8DB7-B3DF87AA49EE} + SolutionGuid = {B47D10E7-E45E-4710-88A3-CAEAF02A87DA} EndGlobalSection EndGlobal diff --git a/Data/WeatherForecast.cs b/Data/WeatherForecast.cs index 085b020..fed09d4 100644 --- a/Data/WeatherForecast.cs +++ b/Data/WeatherForecast.cs @@ -1,15 +1,13 @@ -using System; - -namespace TimePickerProject.Data +namespace CreatingTimePickerSample.Data { public class WeatherForecast { - public DateTime Date { get; set; } + public DateOnly Date { get; set; } public int TemperatureC { get; set; } public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - public string Summary { get; set; } + public string? Summary { get; set; } } -} +} \ No newline at end of file diff --git a/Data/WeatherForecastService.cs b/Data/WeatherForecastService.cs index 20c6fb4..6ab4e6d 100644 --- a/Data/WeatherForecastService.cs +++ b/Data/WeatherForecastService.cs @@ -1,25 +1,20 @@ -using System; -using System.Linq; -using System.Threading.Tasks; - -namespace TimePickerProject.Data +namespace CreatingTimePickerSample.Data { public class WeatherForecastService { private static readonly string[] Summaries = new[] { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; - public Task GetForecastAsync(DateTime startDate) + public Task GetForecastAsync(DateOnly startDate) { - var rng = new Random(); return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = startDate.AddDays(index), - TemperatureC = rng.Next(-20, 55), - Summary = Summaries[rng.Next(Summaries.Length)] + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] }).ToArray()); } } -} +} \ No newline at end of file diff --git a/Pages/Counter.razor b/Pages/Counter.razor index 8641f78..ef23cb3 100644 --- a/Pages/Counter.razor +++ b/Pages/Counter.razor @@ -1,8 +1,10 @@ @page "/counter" +Counter +

Counter

-

Current count: @currentCount

+

Current count: @currentCount

diff --git a/Pages/Error.cshtml b/Pages/Error.cshtml new file mode 100644 index 0000000..57f4c93 --- /dev/null +++ b/Pages/Error.cshtml @@ -0,0 +1,42 @@ +@page +@model CreatingTimePickerSample.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/Pages/Error.cshtml.cs b/Pages/Error.cshtml.cs new file mode 100644 index 0000000..0bf7b68 --- /dev/null +++ b/Pages/Error.cshtml.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Diagnostics; + +namespace CreatingTimePickerSample.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/Pages/Error.razor b/Pages/Error.razor deleted file mode 100644 index 79929d7..0000000 --- a/Pages/Error.razor +++ /dev/null @@ -1,16 +0,0 @@ -@page "/error" - - -

Error.

-

An error occurred while processing your request.

- -

Development Mode

-

- 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. -

\ No newline at end of file diff --git a/Pages/FetchData.razor b/Pages/FetchData.razor index 16508ed..4d31890 100644 --- a/Pages/FetchData.razor +++ b/Pages/FetchData.razor @@ -1,8 +1,9 @@ @page "/fetchdata" - -@using TimePickerProject.Data +@using CreatingTimePickerSample.Data @inject WeatherForecastService ForecastService +Weather forecast +

Weather forecast

This component demonstrates fetching data from a service.

@@ -37,10 +38,10 @@ else } @code { - private WeatherForecast[] forecasts; + private WeatherForecast[]? forecasts; protected override async Task OnInitializedAsync() { - forecasts = await ForecastService.GetForecastAsync(DateTime.Now); + forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now)); } } diff --git a/Pages/Index.razor b/Pages/Index.razor index f6513ca..b997955 100644 --- a/Pages/Index.razor +++ b/Pages/Index.razor @@ -8,7 +8,7 @@ Step="60"> -@code{ +@code { public DateTime TimeValue { get; set; } = new DateTime(2020, 03, 25, 05, 00, 00); public DateTime MinTime { get; set; } = new DateTime(2020, 03, 25, 01, 00, 00); @@ -17,7 +17,7 @@ }