NotificationService, MessageService
This commit is contained in:
@@ -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,6 +13,19 @@ namespace FoodsharingSiegen.Server.BaseClasses
|
||||
/// <seealso cref="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)
|
||||
|
||||
/// <summary>
|
||||
@@ -23,18 +38,15 @@ namespace FoodsharingSiegen.Server.BaseClasses
|
||||
/// </summary>
|
||||
[Inject] private AuditService? AuditService { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override OnInitializedAsync
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the notification (ab)
|
||||
/// </summary>
|
||||
[Inject] protected INotificationService? Notification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ons the initialized (a. beging, 11.04.2022)
|
||||
/// Gets or sets the value of the message (ab)
|
||||
/// </summary>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await AuthService!.Initialize();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
[Inject] protected IMessageService? Message { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -139,6 +139,9 @@ namespace FoodsharingSiegen.Server.Data.Service
|
||||
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();
|
||||
|
||||
if(saveR < 1) return new OperationResult(new Exception("Fehler beim Speichern"));
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<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.Components" Version="1.0.2" />
|
||||
<PackageReference Include="Blazorise.Material" Version="1.0.2" />
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<link href="_content/Blazorise/blazorise.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.Snackbar/blazorise.snackbar.css" rel="stylesheet" />
|
||||
|
||||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered"/>
|
||||
</head>
|
||||
|
||||
@@ -24,3 +24,6 @@
|
||||
<RedirectToLogin/>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
|
||||
<NotificationAlert />
|
||||
<MessageAlert />
|
||||
Reference in New Issue
Block a user