TourIAm/TIAMSharedUI/Pages/Settings.razor.cs

50 lines
1.4 KiB
C#

using AyCode.Interfaces.StorageHandlers;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using TIAMSharedUI.Pages.Components;
using TIAMSharedUI.Resources;
using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models.ClientSide;
namespace TIAMSharedUI.Pages
{
public partial class Settings : ComponentBase
{
[Inject]
public ISecureStorageHandler? secureStorageHandler { get; set; }
[Inject]
public IStringLocalizer<MyResources>? localizer { get; set; }
[Inject]
public ISessionService sessionService { get; set; }
public string Language { get; set; } = "en-US";
private AuthComponent Auth;
private bool UserIsLoggedIn = false;
protected override void OnInitialized()
{
base.OnInitialized();
UserIsLoggedIn = sessionService.IsAuthenticated;
GetCurrentSettings();
}
public void SaveSettings()
{
secureStorageHandler?.SaveToSecureStorageAsync(Setting.Locale, "hu-HU");
}
public void GetCurrentSettings()
{
secureStorageHandler?.GetFromSecureStorageAsync(Setting.Locale);
}
public void ResetSettings()
{
secureStorageHandler?.DeleteFromSecureStorageAsync(Setting.Locale);
}
}
}