bulletboards/ImageBoardServerApp/Shared/Components/UserEntry.razor

37 lines
987 B
Text
Raw Normal View History

2023-02-12 18:06:33 +00:00
@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Data.Repository
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> </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 updateRole()
{
user.Role = selectedRole;
await UsersRepository.updateUserAsync(user);
}
2023-02-12 18:06:33 +00:00
}