bulletboards/ImageBoardServerApp/Shared/Components/UserEntry.razor

47 lines
1.2 KiB
Text
Raw Normal View History

2023-02-12 18:06:33 +00:00
@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Data.Repository
@inject NavigationManager navManager
2023-02-12 18:06:33 +00:00
<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>
<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>&emsp;</span>
<a onclick="@unban()" href="javascript:void(0)">Unban (if banned)</a>
<span> </span>
2023-02-12 18:06:33 +00:00
<span>@user.Role</span>
<br/>
@code {
private string selectedRole;
2023-02-12 18:06:33 +00:00
[Parameter]
[Required]
public UserData user { get; set; }
protected override async Task OnInitializedAsync()
{
selectedRole = user.Role;
}
private async Task unban()
{
user.BanReason = "Not Banned";
user.TimeBanned = -1;
await UsersRepository.updateUserAsync(user);
}
private async Task updateRole()
{
user.Role = selectedRole;
await UsersRepository.updateUserAsync(user);
}
2023-02-12 18:06:33 +00:00
}