109 lines
2.9 KiB
C#
109 lines
2.9 KiB
C#
using Blazorise;
|
|
using FoodsharingSiegen.Contracts.Entity;
|
|
using FoodsharingSiegen.Server.Data.Service;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace FoodsharingSiegen.Server.Pages
|
|
{
|
|
/// <summary>
|
|
/// The profile class (a. beging, 21.05.2022)
|
|
/// </summary>
|
|
public partial class Profile
|
|
{
|
|
#region Dependencies (Injected)
|
|
|
|
/// <summary>
|
|
/// Gets or sets the value of the user service (ab)
|
|
/// </summary>
|
|
[Inject] public UserService? UserService { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Private Properties
|
|
|
|
/// <summary>
|
|
/// Gets or sets the value of the user (ab)
|
|
/// </summary>
|
|
private User User { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// Gets or sets the value of the validations ref (ab)
|
|
/// </summary>
|
|
private Validations? ValidationsRef { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Override OnAfterRenderAsync
|
|
|
|
/// <summary>
|
|
/// Ons the after render using the specified first render (a. beging, 21.05.2022)
|
|
/// </summary>
|
|
/// <param name="firstRender">The first render</param>
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if(firstRender) await ValidationsRef?.ValidateAll()!;
|
|
await base.OnAfterRenderAsync(firstRender);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Override OnInitializedAsync
|
|
|
|
/// <summary>
|
|
/// Ons the initialized (a. beging, 21.05.2022)
|
|
/// </summary>
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
User = CurrentUser.Clone();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Method ChangePassword
|
|
|
|
/// <summary>
|
|
/// Changes the password (a. beging, 23.05.2022)
|
|
/// </summary>
|
|
private async Task ChangePassword()
|
|
{
|
|
await Notification?.Success("Die Funktion ist noch nicht fertig! :)")!;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Method RemoveAccount
|
|
|
|
/// <summary>
|
|
/// Removes the account (a. beging, 23.05.2022)
|
|
/// </summary>
|
|
private async Task RemoveAccount()
|
|
{
|
|
await Notification?.Success("Die Funktion ist noch nicht fertig! :)")!;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Method SaveProfile
|
|
|
|
/// <summary>
|
|
/// Saves the profile (a. beging, 21.05.2022)
|
|
/// </summary>
|
|
private async Task SaveProfile()
|
|
{
|
|
var updateR = await UserService?.Update(User)!;
|
|
if (updateR.Success)
|
|
{
|
|
await Notification?.Success("Profil gespeichert!")!;
|
|
await RefreshState();
|
|
}
|
|
else
|
|
{
|
|
await Notification?.Error(updateR.ErrorMessage)!;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |