@page "/Admin/AspNetUsers/AspNetUserRolleList" @inject Blazored.SessionStorage.ISessionStorageService sessionStorage @using Microsoft.AspNetCore.Authorization; @using Microsoft.AspNetCore.Identity; @inject UserManager _UserManager @inject RoleManager _RoleManager @inherits ListBase @using Syncfusion.Blazor.Grids; @using Syncfusion.Blazor.Buttons; @using Syncfusion.Blazor.Spinner; @using Syncfusion.Blazor.Popups; @using BlazorApp.Helper @using BWPMModels; @using BlazorApp.Controller;

AspNetUserRolle

Passwort-Änderung für @Username
@code{ private bool IsVisible { get; set; } = false; private string Gridid = ""; public List Temp { get; set; } private string newpassword { get; set; } = ""; private string newpassword1 { get; set; } = ""; private string ErrorMsg { get; set; } = ""; private string Username { get; set; } = ""; SfGrid Grid { get; set; } private void OnOverlayclick(MouseEventArgs arg) { this.IsVisible = false; } private void ShowDialog() { this.ErrorMsg = ""; this.IsVisible = true; ; } private void CloseDialog() { this.IsVisible = false; ; } private void SavePasswort() { if (newpassword != newpassword1) { this.ErrorMsg = "Passworte stimmen nicht überein."; } else { IdentityUser objUser = new IdentityUser(); objUser.Id = Gridid; var user = _UserManager.FindByIdAsync(Gridid); var password = _UserManager.PasswordHasher.HashPassword(objUser,newpassword); BWPMModels.AspNetUsers usr = new BWPMModels.AspNetUsers(); usr.Id = Gridid; usr.PasswordHash = password; BlazorApp.Controller.AspNetUserRolleController.PUTPassword(usr); this.IsVisible = false; } } public async Task ToolBarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) { if (args.Item.Text == "Passwort ändern") { var temp = await this.Grid.GetSelectedRecords(); // return the details of selceted record if (temp != null) { Username = temp[0].UserName; Gridid = temp[0].Id; ShowDialog(); } } } public async Task GetSelectedRecords(RowSelectEventArgs args) { } public List GridData { get; set; } public List AspNetUserRolles { get; set; } public List AspNetRoles { get; set; } string userid = ""; public static int? pkey { get; set; } public bool Initial { get; set; } = true; public bool ContinuePaging = true; public bool InitialRender { get; set; } public int Value = 0; // consider that value your querystring contains public int foundrow = 0; protected override void OnInitialized() { /// GridData = OrdersDetails.GetAllRecords(); GridData = BlazorApp.Controller.AspNetUserRolleController.GetAllData(); AspNetRoles = BlazorApp.Controller.AspNetRolesController.GetAllData(); } protected override async Task OnAfterRenderAsync(bool firstRender) { userid = await sessionStorage.GetItemAsync("UserID"); if (userid == null) { var authState = await authenticationStateTask; var userId = authState.User.Claims.FirstOrDefault().Value; var user = authState.User; if (user.Identity.IsAuthenticated) { await sessionStorage.SetItemAsync("UserID", userId); } else { await sessionStorage.SetItemAsync("UserID", userId); } } } private async Task OnBeginHandler(ActionEventArgs Args) { if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save) { if (Args.Action == "Add") { } else { AspNetUserRoles rolle = new AspNetUserRoles(); rolle.RoleId = Args.Data.RoleId; rolle.UserId = Args.Data.Id; BlazorApp.Controller.AspNetUserRolesController.PUT(rolle); } } } public async Task OnCompletedHandler(ActionEventArgs Args) { if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save) { } } public async void RowDataBoundHandler(BeforeDataBoundArgs args) { if (!Initial) { //await Task.Delay(100); //var Idx = await this.Grid.GetRowIndexByPrimaryKey(Convert.ToDouble(Value)); //get index value //this.Grid.SelectRow(Convert.ToDouble(Idx)); } Initial = false; } }