diff --git a/FoodsharingSiegen.Server/BaseClasses/FsBase.cs b/FoodsharingSiegen.Server/BaseClasses/FsBase.cs index 5720d38..d1f1766 100644 --- a/FoodsharingSiegen.Server/BaseClasses/FsBase.cs +++ b/FoodsharingSiegen.Server/BaseClasses/FsBase.cs @@ -1,5 +1,7 @@ +using Blazorise; using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Server.Auth; +using FoodsharingSiegen.Server.Data; using FoodsharingSiegen.Server.Data.Service; using Microsoft.AspNetCore.Components; @@ -11,20 +13,6 @@ namespace FoodsharingSiegen.Server.BaseClasses /// public class FsBase : ComponentBase { - #region Dependencies (Injected) - - /// - /// Gets or sets the value of the auth service (ab) - /// - [Inject] private AuthService? AuthService { get; set; } - - /// - /// Gets or sets the value of the audit service (ab) - /// - [Inject] private AuditService? AuditService { get; set; } - - #endregion - #region Override OnInitializedAsync /// @@ -38,6 +26,30 @@ namespace FoodsharingSiegen.Server.BaseClasses #endregion + #region Dependencies (Injected) + + /// + /// Gets or sets the value of the auth service (ab) + /// + [Inject] private AuthService? AuthService { get; set; } + + /// + /// Gets or sets the value of the audit service (ab) + /// + [Inject] private AuditService? AuditService { get; set; } + + /// + /// Gets or sets the value of the notification (ab) + /// + [Inject] protected INotificationService? Notification { get; set; } + + /// + /// Gets or sets the value of the message (ab) + /// + [Inject] protected IMessageService? Message { get; set; } + + #endregion + /// /// Refreshes the state (a. beging, 21.05.2022) /// diff --git a/FoodsharingSiegen.Server/Data/Service/UserService.cs b/FoodsharingSiegen.Server/Data/Service/UserService.cs index bd026d2..dae35b7 100644 --- a/FoodsharingSiegen.Server/Data/Service/UserService.cs +++ b/FoodsharingSiegen.Server/Data/Service/UserService.cs @@ -138,6 +138,9 @@ namespace FoodsharingSiegen.Server.Data.Service entityUser.Type = user.Type; entityUser.Verified = user.Verified; entityUser.Groups = user.Groups; + + if (!Context.HasChanges()) + return new OperationResult(new Exception("Nichts zum Speichern gefunden")); var saveR = await Context.SaveChangesAsync(); diff --git a/FoodsharingSiegen.Server/FoodsharingSiegen.Server.csproj b/FoodsharingSiegen.Server/FoodsharingSiegen.Server.csproj index a76b7ed..e6f2197 100644 --- a/FoodsharingSiegen.Server/FoodsharingSiegen.Server.csproj +++ b/FoodsharingSiegen.Server/FoodsharingSiegen.Server.csproj @@ -13,6 +13,7 @@ + diff --git a/FoodsharingSiegen.Server/Pages/Profile.razor.cs b/FoodsharingSiegen.Server/Pages/Profile.razor.cs index 4ca499b..8431104 100644 --- a/FoodsharingSiegen.Server/Pages/Profile.razor.cs +++ b/FoodsharingSiegen.Server/Pages/Profile.razor.cs @@ -18,7 +18,7 @@ namespace FoodsharingSiegen.Server.Pages [Inject] public UserService? UserService { get; set; } #endregion - + #region Private Properties /// @@ -69,7 +69,15 @@ namespace FoodsharingSiegen.Server.Pages private async Task SaveProfile() { var updateR = await UserService?.Update(User)!; - if (updateR.Success) await RefreshState(); + if (updateR.Success) + { + await Notification?.Success("Profil gespeichert!")!; + await RefreshState(); + } + else + { + await Notification?.Error(updateR.ErrorMessage)!; + } } #endregion diff --git a/FoodsharingSiegen.Server/Pages/_Layout.cshtml b/FoodsharingSiegen.Server/Pages/_Layout.cshtml index 58146aa..6d22dbd 100644 --- a/FoodsharingSiegen.Server/Pages/_Layout.cshtml +++ b/FoodsharingSiegen.Server/Pages/_Layout.cshtml @@ -23,6 +23,7 @@ + diff --git a/FoodsharingSiegen.Server/Shared/MainLayout.razor b/FoodsharingSiegen.Server/Shared/MainLayout.razor index 96922fd..288246d 100644 --- a/FoodsharingSiegen.Server/Shared/MainLayout.razor +++ b/FoodsharingSiegen.Server/Shared/MainLayout.razor @@ -23,4 +23,7 @@ - \ No newline at end of file + + + + \ No newline at end of file