Show user name while edit
This commit is contained in:
@ -17,6 +17,11 @@
|
||||
@errorMessage
|
||||
</RadzenAlert>
|
||||
<RadzenStack Gap="1rem" class="rz-p-sm-4">
|
||||
<RadzenFormField Text="Логин" Variant="Variant.Outlined">
|
||||
<ChildContent>
|
||||
<RadzenTextBox Name="UserName" @bind-Value=@Input.UserName Disabled="true" />
|
||||
</ChildContent>
|
||||
</RadzenFormField>
|
||||
<RadzenFormField Text="Роль" Variant="Variant.Outlined">
|
||||
<ChildContent>
|
||||
<RadzenDropDown Data="@roles" TextProperty="Name" ValueProperty="Id" @bind-Value="@Input.RoleId" Disabled="@Input.RoleDisabled" Name="Role" style="width: 100%" />
|
||||
@ -54,6 +59,8 @@
|
||||
@code {
|
||||
sealed class InputModel
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
|
||||
public bool RoleDisabled { get; set; }
|
||||
|
||||
public string RoleId { get; set; }
|
||||
@ -72,10 +79,7 @@
|
||||
public required string CurrentUserId { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public required string UserId { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public required string RoleId { get; set; }
|
||||
public required AppUserWithRole UserWithRole { get; set; }
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
InputModel Input { get; set; } = new();
|
||||
@ -84,8 +88,9 @@
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
Input.RoleDisabled = CurrentUserId == UserId;
|
||||
Input.RoleId = RoleId;
|
||||
Input.UserName = UserWithRole.User.UserName;
|
||||
Input.RoleDisabled = CurrentUserId == UserWithRole.User.Id;
|
||||
Input.RoleId = UserWithRole.Role.Id;
|
||||
|
||||
roles = await RoleManager.Roles.OrderBy(x => x.Priority).ToListAsync();
|
||||
}
|
||||
@ -99,7 +104,7 @@
|
||||
|
||||
try
|
||||
{
|
||||
await UsersService.UpdateUserAsync(UserId, input.RoleId, input.Password);
|
||||
await UsersService.UpdateUserAsync(UserWithRole.User.Id, input.RoleId, input.Password);
|
||||
|
||||
DialogService.Close(true);
|
||||
}
|
||||
|
||||
@ -110,8 +110,7 @@
|
||||
new Dictionary<string, object>()
|
||||
{
|
||||
{ nameof(Dialogs.EditUser.CurrentUserId), currentUserId },
|
||||
{ nameof(Dialogs.EditUser.UserId), userWithRole.User.Id },
|
||||
{ nameof(Dialogs.EditUser.RoleId), userWithRole.Role.Id }
|
||||
{ nameof(Dialogs.EditUser.UserWithRole), userWithRole }
|
||||
},
|
||||
new DialogOptions()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user