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,20 +13,6 @@ namespace FoodsharingSiegen.Server.BaseClasses
|
||||
/// <seealso cref="ComponentBase"/>
|
||||
public class FsBase : ComponentBase
|
||||
{
|
||||
#region Dependencies (Injected)
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the auth service (ab)
|
||||
/// </summary>
|
||||
[Inject] private AuthService? AuthService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the audit service (ab)
|
||||
/// </summary>
|
||||
[Inject] private AuditService? AuditService { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override OnInitializedAsync
|
||||
|
||||
/// <summary>
|
||||
@@ -38,6 +26,30 @@ namespace FoodsharingSiegen.Server.BaseClasses
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dependencies (Injected)
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the auth service (ab)
|
||||
/// </summary>
|
||||
[Inject] private AuthService? AuthService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the audit service (ab)
|
||||
/// </summary>
|
||||
[Inject] private AuditService? AuditService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the notification (ab)
|
||||
/// </summary>
|
||||
[Inject] protected INotificationService? Notification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the message (ab)
|
||||
/// </summary>
|
||||
[Inject] protected IMessageService? Message { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the state (a. beging, 21.05.2022)
|
||||
/// </summary>
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
[Inject] public UserService? UserService { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -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>
|
||||
|
||||
@@ -23,4 +23,7 @@
|
||||
<NotAuthorized>
|
||||
<RedirectToLogin/>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
</AuthorizeView>
|
||||
|
||||
<NotificationAlert />
|
||||
<MessageAlert />
|
||||
Reference in New Issue
Block a user