NotificationService, MessageService

This commit is contained in:
Andre Beging
2022-05-23 11:54:05 +02:00
parent b16951a1a6
commit d8662c4876
6 changed files with 45 additions and 17 deletions

View File

@@ -1,5 +1,7 @@
using Blazorise;
using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Server.Auth; using FoodsharingSiegen.Server.Auth;
using FoodsharingSiegen.Server.Data;
using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Data.Service;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
@@ -11,6 +13,19 @@ namespace FoodsharingSiegen.Server.BaseClasses
/// <seealso cref="ComponentBase"/> /// <seealso cref="ComponentBase"/>
public class FsBase : ComponentBase public class FsBase : ComponentBase
{ {
#region Override OnInitializedAsync
/// <summary>
/// Ons the initialized (a. beging, 11.04.2022)
/// </summary>
protected override async Task OnInitializedAsync()
{
await AuthService!.Initialize();
await base.OnInitializedAsync();
}
#endregion
#region Dependencies (Injected) #region Dependencies (Injected)
/// <summary> /// <summary>
@@ -23,18 +38,15 @@ namespace FoodsharingSiegen.Server.BaseClasses
/// </summary> /// </summary>
[Inject] private AuditService? AuditService { get; set; } [Inject] private AuditService? AuditService { get; set; }
#endregion /// <summary>
/// Gets or sets the value of the notification (ab)
#region Override OnInitializedAsync /// </summary>
[Inject] protected INotificationService? Notification { get; set; }
/// <summary> /// <summary>
/// Ons the initialized (a. beging, 11.04.2022) /// Gets or sets the value of the message (ab)
/// </summary> /// </summary>
protected override async Task OnInitializedAsync() [Inject] protected IMessageService? Message { get; set; }
{
await AuthService!.Initialize();
await base.OnInitializedAsync();
}
#endregion #endregion

View File

@@ -139,6 +139,9 @@ namespace FoodsharingSiegen.Server.Data.Service
entityUser.Verified = user.Verified; entityUser.Verified = user.Verified;
entityUser.Groups = user.Groups; entityUser.Groups = user.Groups;
if (!Context.HasChanges())
return new OperationResult(new Exception("Nichts zum Speichern gefunden"));
var saveR = await Context.SaveChangesAsync(); var saveR = await Context.SaveChangesAsync();
if(saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern")); if(saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern"));

View File

@@ -13,6 +13,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Blazorise.DataGrid" Version="1.0.2" /> <PackageReference Include="Blazorise.DataGrid" Version="1.0.2" />
<PackageReference Include="Blazorise.Snackbar" Version="1.0.2" />
<PackageReference Include="Blazorise.Icons.Material" Version="1.0.2" /> <PackageReference Include="Blazorise.Icons.Material" Version="1.0.2" />
<PackageReference Include="Blazorise.Components" Version="1.0.2" /> <PackageReference Include="Blazorise.Components" Version="1.0.2" />
<PackageReference Include="Blazorise.Material" Version="1.0.2" /> <PackageReference Include="Blazorise.Material" Version="1.0.2" />

View File

@@ -69,7 +69,15 @@ namespace FoodsharingSiegen.Server.Pages
private async Task SaveProfile() private async Task SaveProfile()
{ {
var updateR = await UserService?.Update(User)!; 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 #endregion

View File

@@ -23,6 +23,7 @@
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" /> <link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Material/blazorise.material.css" rel="stylesheet" /> <link href="_content/Blazorise.Material/blazorise.material.css" rel="stylesheet" />
<link href="_content/Blazorise.Icons.Material/blazorise.icons.material.css" rel="stylesheet" /> <link href="_content/Blazorise.Icons.Material/blazorise.icons.material.css" rel="stylesheet" />
<link href="_content/Blazorise.Snackbar/blazorise.snackbar.css" rel="stylesheet" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered"/> <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered"/>
</head> </head>

View File

@@ -24,3 +24,6 @@
<RedirectToLogin/> <RedirectToLogin/>
</NotAuthorized> </NotAuthorized>
</AuthorizeView> </AuthorizeView>
<NotificationAlert />
<MessageAlert />