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>
|
||||
public FsContext(DbContextOptions<FsContext> options) : base(options)
|
||||
{
|
||||
// Database.EnsureCreated();
|
||||
Database.EnsureCreated();
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
public class AndresTestException : Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
@page "/profile"
|
||||
|
||||
@using FoodsharingSiegen.Server.Dialogs
|
||||
@using FoodsharingSiegen.Server.BaseClasses
|
||||
|
||||
@inherits FsBase
|
||||
@@ -31,6 +32,8 @@
|
||||
</Fields>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<SetPasswordModal @ref="PasswordModal" OnPasswortSet="OnPasswordSet"></SetPasswordModal>
|
||||
@@ -1,6 +1,7 @@
|
||||
using Blazorise;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using FoodsharingSiegen.Server.Dialogs;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Pages
|
||||
@@ -11,16 +12,25 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
public partial class Profile
|
||||
{
|
||||
#region Dependencies (Injected)
|
||||
|
||||
|
||||
#region Dependencies (Injected)
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the user service (ab)
|
||||
/// </summary>
|
||||
[Inject] public UserService? UserService { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#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 user (ab)
|
||||
/// </summary>
|
||||
@@ -73,6 +83,21 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
|
||||
#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
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,41 +12,49 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
public partial class Users
|
||||
{
|
||||
#region Dependencies (Injected)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary> Gets or sets the user service. </summary>
|
||||
///
|
||||
/// <value> The user service. </value>
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
[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
|
||||
|
||||
#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>
|
||||
/// Gets or sets the value of the user list (ab)
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
#region Override OnAfterRenderAsync
|
||||
@@ -65,35 +73,6 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
|
||||
#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
|
||||
|
||||
/// <summary>
|
||||
@@ -109,6 +88,21 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
|
||||
#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
|
||||
|
||||
/// <summary>
|
||||
@@ -119,13 +113,9 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
{
|
||||
var addUserR = await UserService.AddUserAsync(arg.Item);
|
||||
if (!addUserR.Success)
|
||||
{
|
||||
//Todo Error Toast [01.04.22 - Andre Beging]
|
||||
}
|
||||
await Notification?.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!;
|
||||
else
|
||||
{
|
||||
await LoadUsers();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -144,22 +134,5 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
}
|
||||
|
||||
#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