Code Cleanup und Passwort ändern im Profil
This commit is contained in:
@@ -41,7 +41,7 @@ namespace FoodsharingSiegen.Server.Data
|
|||||||
/// <param name="options">The options (ab)</param>
|
/// <param name="options">The options (ab)</param>
|
||||||
public FsContext(DbContextOptions<FsContext> options) : base(options)
|
public FsContext(DbContextOptions<FsContext> options) : base(options)
|
||||||
{
|
{
|
||||||
// Database.EnsureCreated();
|
Database.EnsureCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -57,6 +57,11 @@ namespace FoodsharingSiegen.Server.Data
|
|||||||
return ChangeTracker.Entries().Any(e => e.State is EntityState.Added or EntityState.Modified or EntityState.Deleted);
|
return ChangeTracker.Entries().Any(e => e.State is EntityState.Added or EntityState.Modified or EntityState.Deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AndresTestException : Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
@page "/profile"
|
@page "/profile"
|
||||||
|
|
||||||
|
@using FoodsharingSiegen.Server.Dialogs
|
||||||
@using FoodsharingSiegen.Server.BaseClasses
|
@using FoodsharingSiegen.Server.BaseClasses
|
||||||
|
|
||||||
@inherits FsBase
|
@inherits FsBase
|
||||||
@@ -31,6 +32,8 @@
|
|||||||
</Fields>
|
</Fields>
|
||||||
|
|
||||||
<h3>Sicherheit</h3>
|
<h3>Sicherheit</h3>
|
||||||
<Button Color="Color.Primary" Class="mb-2" Clicked="ChangePassword">Passwort ändern</Button>
|
<Button Color="Color.Primary" Class="mb-2" Clicked="() => PasswordModal?.Show(User)!">Passwort ändern</Button>
|
||||||
<Button Color="Color.Danger" Class="mb-2" Clicked="RemoveAccount">Konto löschen</Button>
|
<Button Color="Color.Danger" Class="mb-2" Clicked="RemoveAccount">Konto löschen</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SetPasswordModal @ref="PasswordModal" OnPasswortSet="OnPasswordSet"></SetPasswordModal>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Blazorise;
|
using Blazorise;
|
||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
using FoodsharingSiegen.Server.Data.Service;
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
|
using FoodsharingSiegen.Server.Dialogs;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace FoodsharingSiegen.Server.Pages
|
namespace FoodsharingSiegen.Server.Pages
|
||||||
@@ -12,6 +13,8 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
{
|
{
|
||||||
#region Dependencies (Injected)
|
#region Dependencies (Injected)
|
||||||
|
|
||||||
|
#region Dependencies (Injected)
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value of the user service (ab)
|
/// Gets or sets the value of the user service (ab)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -19,8 +22,15 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Properties
|
#region Private Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the password modal (ab)
|
||||||
|
/// </summary>
|
||||||
|
private SetPasswordModal? PasswordModal { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value of the user (ab)
|
/// Gets or sets the value of the user (ab)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -73,6 +83,21 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Method OnPasswordSet
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ons the password set using the specified arg (a. beging, 23.05.2022)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg">The arg</param>
|
||||||
|
private async Task OnPasswordSet(User arg)
|
||||||
|
{
|
||||||
|
var setPasswordR = await UserService?.SetPassword(arg)!;
|
||||||
|
if(setPasswordR.Success)
|
||||||
|
await Notification?.Success("Dein neues Passwort wurde gespeichert")!;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Method RemoveAccount
|
#region Private Method RemoveAccount
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -20,33 +20,41 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
[Inject] public UserService UserService { get; set; } = null!;
|
[Inject] public UserService UserService { get; set; } = null!;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Properties
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the value of the user data grid (ab)
|
|
||||||
/// </summary>
|
|
||||||
public DataGrid<User> UserDataGrid { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Properties
|
#region Private Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the password modal (ab)
|
||||||
|
/// </summary>
|
||||||
|
private SetPasswordModal PasswordModal { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the selected company texts (ab)
|
||||||
|
/// </summary>
|
||||||
|
private List<string> SelectedCompanyTexts { get; set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the selected user (ab)
|
||||||
|
/// </summary>
|
||||||
|
private User? SelectedUser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the user data grid (ab)
|
||||||
|
/// </summary>
|
||||||
|
private DataGrid<User> UserDataGrid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value of the user groups (ab)
|
||||||
|
/// </summary>
|
||||||
|
private IEnumerable<UserGroup> UserGroups => Enum.GetValues<UserGroup>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value of the user list (ab)
|
/// Gets or sets the value of the user list (ab)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<User>? UserList { get; set; }
|
private List<User>? UserList { get; set; }
|
||||||
|
|
||||||
public User? SelectedUser { get; set; }
|
|
||||||
|
|
||||||
public IEnumerable<UserGroup> UserGroups => Enum.GetValues<UserGroup>();
|
|
||||||
|
|
||||||
public List<Company> Companies { get; set; }
|
|
||||||
public List<UserGroup> SelectedCompanies { get; set; }
|
|
||||||
public List<string> SelectedCompanyTexts { get; set; } = new();
|
|
||||||
public SetPasswordModal PasswordModal { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Override OnAfterRenderAsync
|
#region Override OnAfterRenderAsync
|
||||||
@@ -65,35 +73,6 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
protected override void OnInitialized()
|
|
||||||
{
|
|
||||||
Companies = new List<Company>
|
|
||||||
{
|
|
||||||
new Company{Name = "Germany", ISO = "DE"},
|
|
||||||
new Company{Name = "USA", ISO = "US"},
|
|
||||||
new Company{Name = "England", ISO = "GB"},
|
|
||||||
new Company{Name = "Austria", ISO = "AT"}
|
|
||||||
};
|
|
||||||
|
|
||||||
SelectedCompanies = new List<UserGroup> {UserGroups.ElementAt(2)};
|
|
||||||
|
|
||||||
base.OnInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Private Method Chang
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Changs the context (a. beging, 01.04.2022)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context">The context</param>
|
|
||||||
/// <param name="type">The type</param>
|
|
||||||
private void Chang(CellEditContext<User> context, UserType type)
|
|
||||||
{
|
|
||||||
context.Item.Type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Method LoadUsers
|
#region Private Method LoadUsers
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -109,6 +88,21 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Method OnPasswordSet
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ons the password set using the specified user (a. beging, 23.05.2022)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user</param>
|
||||||
|
private async Task OnPasswordSet(User user)
|
||||||
|
{
|
||||||
|
var setPasswordR = await UserService?.SetPassword(user)!;
|
||||||
|
if(setPasswordR.Success)
|
||||||
|
await Notification?.Success("Passwort gespeichert")!;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Method RowInserted
|
#region Private Method RowInserted
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -119,13 +113,9 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
{
|
{
|
||||||
var addUserR = await UserService.AddUserAsync(arg.Item);
|
var addUserR = await UserService.AddUserAsync(arg.Item);
|
||||||
if (!addUserR.Success)
|
if (!addUserR.Success)
|
||||||
{
|
await Notification?.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!;
|
||||||
//Todo Error Toast [01.04.22 - Andre Beging]
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
await LoadUsers();
|
await LoadUsers();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -144,22 +134,5 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private async Task SelectedChanged(List<UserGroup> arg)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task OnPasswordSet(User user)
|
|
||||||
{
|
|
||||||
var result = await UserService.SetPassword(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Company
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public string ISO { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user