Restore .NET 9.0 version and update Index.razor.cs per feedback

Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-08-18 17:21:48 +00:00
parent c7221ea021
commit 983bac41b2
5 changed files with 12 additions and 21 deletions

View file

@ -15,22 +15,17 @@ namespace ShiftScheduler.Client.Pages
private List<DateTime> DaysInMonth { get; set; } = new(); private List<DateTime> DaysInMonth { get; set; } = new();
private List<Shift> Shifts { get; set; } = new(); private List<Shift> Shifts { get; set; } = new();
private Dictionary<DateTime, string> SelectedSchedule { get; set; } = new(); private Dictionary<DateTime, string> SelectedSchedule { get; set; } = new();
private int CurrentMonth { get; set; }
private int CurrentYear { get; set; }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
var (nextMonth, year) = GetNextMonthAndYear(); var (EditMonth, EditYear) = GetNextMonthAndYear();
CurrentMonth = nextMonth;
CurrentYear = year;
DaysInMonth = Enumerable.Range(1, DateTime.DaysInMonth(year, nextMonth)) DaysInMonth = Enumerable.Range(1, DateTime.DaysInMonth(EditYear, EditMonth))
.Select(d => new DateTime(year, nextMonth, d)) .Select(d => new DateTime(EditYear, EditMonth, d))
.ToList(); .ToList();
Shifts = await HttpClient.GetFromJsonAsync<List<Shift>>("api/shift/shifts") ?? new(); Shifts = await HttpClient.GetFromJsonAsync<List<Shift>>("api/shift/shifts") ?? new();
// Load saved schedule for this month
await LoadScheduleFromStorage(); await LoadScheduleFromStorage();
} }
@ -70,9 +65,8 @@ namespace ShiftScheduler.Client.Pages
{ {
try try
{ {
var storageKey = $"ShiftSchedule_{CurrentYear}_{CurrentMonth:D2}"; var storageKey = $"ShiftSchedule_{EditYear}_{EditMonth:D2}";
// Convert DateTime keys to string for JSON serialization
var serializableSchedule = SelectedSchedule.ToDictionary( var serializableSchedule = SelectedSchedule.ToDictionary(
kvp => kvp.Key.ToString("yyyy-MM-dd"), kvp => kvp.Key.ToString("yyyy-MM-dd"),
kvp => kvp.Value kvp => kvp.Value
@ -83,7 +77,6 @@ namespace ShiftScheduler.Client.Pages
} }
catch (Exception) catch (Exception)
{ {
// Silently fail if localStorage is not available
} }
} }
@ -91,7 +84,7 @@ namespace ShiftScheduler.Client.Pages
{ {
try try
{ {
var storageKey = $"ShiftSchedule_{CurrentYear}_{CurrentMonth:D2}"; var storageKey = $"ShiftSchedule_{EditYear}_{EditMonth:D2}";
var json = await JSRuntime.InvokeAsync<string>("localStorage.getItem", storageKey); var json = await JSRuntime.InvokeAsync<string>("localStorage.getItem", storageKey);
if (!string.IsNullOrEmpty(json)) if (!string.IsNullOrEmpty(json))
@ -99,7 +92,6 @@ namespace ShiftScheduler.Client.Pages
var serializableSchedule = JsonSerializer.Deserialize<Dictionary<string, string>>(json); var serializableSchedule = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
if (serializableSchedule != null) if (serializableSchedule != null)
{ {
// Convert string keys back to DateTime
SelectedSchedule = serializableSchedule.ToDictionary( SelectedSchedule = serializableSchedule.ToDictionary(
kvp => DateTime.Parse(kvp.Key), kvp => DateTime.Parse(kvp.Key),
kvp => kvp.Value kvp => kvp.Value
@ -109,7 +101,6 @@ namespace ShiftScheduler.Client.Pages
} }
catch (Exception) catch (Exception)
{ {
// Silently fail if localStorage is not available or data is corrupted
SelectedSchedule = new Dictionary<DateTime, string>(); SelectedSchedule = new Dictionary<DateTime, string>();
} }
} }

View file

@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.8" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.8" PrivateAssets="all" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.8" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.8" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.8" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>