Implement Appsettings

This commit is contained in:
Andre Beging
2025-03-27 09:06:43 +01:00
parent 48db8db8ae
commit 8ea8130c69
10 changed files with 109 additions and 61 deletions

View File

@@ -1,21 +1,73 @@
using Blazorise;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Auth;
using FoodsharingSiegen.Server.Data.Service;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
namespace FoodsharingSiegen.Server.BaseClasses
{
/// <summary>
/// The fs base class (a. beging, 08.04.2022)
/// The fs base class (a. beging, 08.04.2022)
/// </summary>
/// <seealso cref="ComponentBase"/>
/// <seealso cref="ComponentBase" />
public class FsBase : ComponentBase
{
#region Dependencies
[Inject]
private IOptions<AppSettings> AppSettingsContainer { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the audit service (ab)
/// </summary>
[Inject]
private AuditService AuditService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the auth service (ab)
/// </summary>
[Inject]
protected AuthService AuthService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the message (ab)
/// </summary>
[Inject]
protected IMessageService Message { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the navigation manager (ab)
/// </summary>
[Inject]
protected NavigationManager NavigationManager { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the notification (ab)
/// </summary>
[Inject]
protected INotificationService Notification { get; set; } = null!;
#endregion
#region Protected Properties
/// Provides application-specific settings used to configure the behavior and display of the application.
/// The AppSettings class encapsulates information such as the application title and other configurable parameters.
protected AppSettings AppSettings => AppSettingsContainer.Value;
/// <summary>
/// Gets the value of the current user (ab)
/// </summary>
protected User CurrentUser => AuthService?.User ?? new User();
#endregion
#region Override OnInitializedAsync
/// <summary>
/// Ons the initialized (a. beging, 11.04.2022)
/// Ons the initialized (a. beging, 11.04.2022)
/// </summary>
protected override async Task OnInitializedAsync()
{
@@ -25,46 +77,16 @@ namespace FoodsharingSiegen.Server.BaseClasses
#endregion
#region Dependencies (Injected)
#region Protected Method RefreshState
/// <summary>
/// Gets or sets the value of the auth service (ab)
/// </summary>
[Inject] protected AuthService AuthService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the audit service (ab)
/// </summary>
[Inject] private AuditService AuditService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the notification (ab)
/// </summary>
[Inject] protected INotificationService Notification { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the message (ab)
/// </summary>
[Inject] protected IMessageService Message { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the navigation manager (ab)
/// </summary>
[Inject] protected NavigationManager NavigationManager { get; set; } = null!;
#endregion
/// <summary>
/// Refreshes the state (a. beging, 21.05.2022)
/// Refreshes the state (a. beging, 21.05.2022)
/// </summary>
protected async Task RefreshState()
{
await AuthService?.RefreshState()!;
}
/// <summary>
/// Gets the value of the current user (ab)
/// </summary>
protected User CurrentUser => AuthService?.User ?? new User();
#endregion
}
}