diff --git a/src/DotNetEd.CoreAdmin.DemoAppDotNet6/Models/TestDbContext.cs b/src/DotNetEd.CoreAdmin.DemoAppDotNet6/Models/TestDbContext.cs index f70f362..4855b07 100644 --- a/src/DotNetEd.CoreAdmin.DemoAppDotNet6/Models/TestDbContext.cs +++ b/src/DotNetEd.CoreAdmin.DemoAppDotNet6/Models/TestDbContext.cs @@ -41,7 +41,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) Date = DateTime.Now, DateOnly = DateOnly.FromDateTime(DateTime.Now), TimeOnly = TimeOnly.FromDateTime(DateTime.Now), - TimeSpan = TimeSpan.FromHours(3), + TimeSpan = new TimeSpan(3, 2, 1, 44, 55555), Price = Random.Shared.NextDouble() }); } diff --git a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/Date.cshtml b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/Date.cshtml index b45a7ec..3237094 100644 --- a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/Date.cshtml +++ b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/Date.cshtml @@ -1,19 +1,28 @@ @model object -@if (Model is DateTime?) +@switch (Model) { - var date = (DateTime?)Model; - @Html.TextBox("", (date.HasValue ? date.Value.ToString("yyyy-MM-dd") : string.Empty), new { type = "date", @class = "datePicker form-control" }) -} + case DateTime dateTimeValue: + { + @Html.TextBox("", dateTimeValue.ToString("yyyy-MM-dd"), new { type = "date", @class = "datePicker form-control" }); + break; + } -@if (Model is DateTimeOffset?) -{ - var date = (DateTimeOffset?)Model; - @Html.TextBox("", (date.HasValue ? date.Value.ToString("yyyy-MM-dd") : string.Empty), new { type = "date", @class = "datePicker form-control" }) -} + case DateTimeOffset dateTimeOffsetValue: + { + @Html.TextBox("", dateTimeOffsetValue.ToString("yyyy-MM-dd"), new { type = "date", @class = "datePicker form-control" }); + break; + } -@if (Model is DateOnly?) -{ - var date = (DateOnly?)Model; - @Html.TextBox("", (date.HasValue ? date.Value.ToString("yyyy-MM-dd") : string.Empty), new { type = "date", @class = "datePicker form-control" }) + case DateOnly dateOnlyValue: + { + @Html.TextBox("", dateOnlyValue.ToString("yyyy-MM-dd"), new { type = "date", @class = "datePicker form-control" }); + break; + } + + default: + { + @Html.TextBox("", null, new { type = "date", @class = "datePicker form-control" }) + break; + } } diff --git a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateOnly.cshtml b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateOnly.cshtml index 5e3d01f..86315a3 100644 --- a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateOnly.cshtml +++ b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateOnly.cshtml @@ -1,2 +1,2 @@ @model DateOnly? -@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("O") : string.Empty), new { type = "date", @class = "datePicker form-control" }) +@Html.TextBox("", Model?.ToString("yyyy-MM-dd"), new { type = "date", @class = "datePicker form-control" }) diff --git a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTime.cshtml b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTime.cshtml index 30f6361..80b5417 100644 --- a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTime.cshtml +++ b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTime.cshtml @@ -1,2 +1,2 @@ @model DateTime? -@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("s") : string.Empty), new { type = "datetime-local", @class = "datePicker form-control" }) \ No newline at end of file +@Html.TextBox("", Model?.ToLocalTime().ToString("yyyy-MM-ddTHH:mm:ss.fff"), new { type = "datetime-local", @class = "datePicker form-control" }) diff --git a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTimeOffset.cshtml b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTimeOffset.cshtml index 9b2e9a4..2a856ca 100644 --- a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTimeOffset.cshtml +++ b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/DateTimeOffset.cshtml @@ -1,2 +1,2 @@ @model DateTimeOffset? -@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("s") : string.Empty), new { type = "datetime-local", @class = "datePicker form-control" }) \ No newline at end of file +@Html.TextBox("", Model?.ToLocalTime().ToString("yyyy-MM-ddTHH:mm:ss.fff"), new { type = "datetime-local", @class = "datePicker form-control" }) diff --git a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeOnly.cshtml b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeOnly.cshtml index f86a665..92db04b 100644 --- a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeOnly.cshtml +++ b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeOnly.cshtml @@ -1,2 +1,2 @@ @model TimeOnly? -@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("HH:mm:ss") : string.Empty), new { type = "time", @class = "form-control" }) +@Html.TextBox("", Model?.ToString("HH:mm:ss.fff"), new { type = "time", @class = "form-control" }) diff --git a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeSpan.cshtml b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeSpan.cshtml index ca8fab7..73e7718 100644 --- a/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeSpan.cshtml +++ b/src/DotNetEd.CoreAdmin/Views/Shared/EditorTemplates/TimeSpan.cshtml @@ -1,2 +1,2 @@ @model TimeSpan? -@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("c") : string.Empty), new { type = "time", @class = "form-control" }) +@Html.TextBox("", Model?.Ticks, new { type = "number", @class = "text-box single-line form-control number-form-control", max = Int64.MaxValue, min = Int64.MinValue })