using System.Net.Http.Json; using eNavigator.Routes; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; namespace eNavigator.Pages { public partial class Weather { [Inject] private NavigationManager NavigationManager { get; set; } = default!; [Inject] private AuthenticationStateProvider authenticationStateProvider { get; set; } = default; public WeatherForecast[]? forecasts; protected override async Task OnInitializedAsync() { AuthenticationState authenticationState = await authenticationStateProvider.GetAuthenticationStateAsync(); if(!authenticationState.User.Identity.IsAuthenticated) { NavigationManager.NavigateTo(PageRoute.Login); } forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); } public class WeatherForecast { public DateOnly Date { get; set; } public int TemperatureC { get; set; } public string? Summary { get; set; } public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); } } }