feat: added Role updating to the Users menu

This commit is contained in:
limited_dev 2023-02-13 22:34:30 +01:00
parent a62912d6de
commit 7f138cf73f

View file

@ -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);
}
}