feat: added Role updating to the Users menu
This commit is contained in:
parent
a62912d6de
commit
7f138cf73f
1 changed files with 29 additions and 0 deletions
|
@ -1,16 +1,45 @@
|
|||
@using System.ComponentModel.DataAnnotations
|
||||
@using ImageBoardServerApp.Data.Repository
|
||||
<span>@user.Email | </span>
|
||||
<span>@user.Posts.Count Posts | </span>
|
||||
<span>@user.Comments.Count Comments | </span>
|
||||
<span>@user.SubmittedReports.Count Reports submitted | </span>
|
||||
<span>@user.RecivedReports.Count Reports recived | </span>
|
||||
<a onclick="@editF()" href="javascript:void(0)">Edit</a>
|
||||
<span> </span>
|
||||
<select name="role" id="role" @bind="@selectedRole">
|
||||
<option value="User">User</option>
|
||||
<option value="Mod">Mod</option>
|
||||
<option value="Admin">Admin</option>
|
||||
</select>
|
||||
<a onclick="@updateRole()" href="javascript:void(0)" >Update Role</a>
|
||||
<span> </span>
|
||||
<span>@user.Role</span>
|
||||
<br/>
|
||||
|
||||
@code {
|
||||
private string selectedRole;
|
||||
private bool edit = false;
|
||||
|
||||
[Parameter]
|
||||
[Required]
|
||||
public UserData user { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
edit = false;
|
||||
selectedRole = user.Role;
|
||||
}
|
||||
|
||||
private async Task editF()
|
||||
{
|
||||
edit = !edit;
|
||||
}
|
||||
|
||||
private async Task updateRole()
|
||||
{
|
||||
user.Role = selectedRole;
|
||||
await UsersRepository.updateUserAsync(user);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue