using Blazorise; using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Server.Data.Service; using Microsoft.AspNetCore.Components; namespace FoodsharingSiegen.Server.Pages { /// /// The profile class (a. beging, 21.05.2022) /// public partial class Profile { #region Dependencies (Injected) /// /// Gets or sets the value of the user service (ab) /// [Inject] public UserService? UserService { get; set; } #endregion #region Private Properties /// /// Gets or sets the value of the user (ab) /// private User User { get; set; } = new(); /// /// Gets or sets the value of the validations ref (ab) /// private Validations? ValidationsRef { get; set; } #endregion #region Override OnAfterRenderAsync /// /// Ons the after render using the specified first render (a. beging, 21.05.2022) /// /// The first render protected override async Task OnAfterRenderAsync(bool firstRender) { if(firstRender) await ValidationsRef?.ValidateAll()!; await base.OnAfterRenderAsync(firstRender); } #endregion #region Override OnInitializedAsync /// /// Ons the initialized (a. beging, 21.05.2022) /// protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); User = CurrentUser.Clone(); } #endregion #region Private Method SaveProfile /// /// Saves the profile (a. beging, 21.05.2022) /// private async Task SaveProfile() { var updateR = await UserService?.Update(User)!; if (updateR.Success) await RefreshState(); } #endregion } }