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

View file

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

View file

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

View file

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

View file

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