@page "/sys/modtools/banandordel/{targetuserid}/{board}/{type}/{threadid}/{targetid}" @using ImageBoardServerApp.Data.Repository @using System.ComponentModel.DataAnnotations @inject NavigationManager navManager @inject IJSRuntime js

[View Thread]


@if (type == "op") { } else if (type == "comment") { } else {

This is not a valid type.

}


Ban User: 1h 2h 1d 1w 1m 1yr
@code { public string timetoBan { get; set; } public string reason { get; set; } public UserData user { get; set; } public PostData post { get; set; } public CommentData comment { get; set; } private async Task banTarget(int hours) { UserData ud = await UsersRepository.getUserByIdAsync(int.Parse(targetuserid)); ud.TimeBanned = DateTimeOffset.Now.ToUnixTimeMilliseconds() + (hours * 3600000); if (reason == "") { reason = "not specified"; } ud.BanReason = reason; await UsersRepository.updateUserAsync(ud); navManager.NavigateTo("/@board/", true, true); } protected override async Task OnParametersSetAsync() { if (!int.TryParse(targetid, out _) || !int.TryParse(targetuserid, out _)) { navManager.NavigateTo("/sys/dead", true); return; } var targeti = int.Parse(targetid); var targetuseri = int.Parse(targetuserid); var u = await UsersRepository.getUserByIdAsync(targetuseri); if (u == null) { navManager.NavigateTo("/sys/dead", true); return; } if (targetuseri != u.UserID) { navManager.NavigateTo("/sys/dead", true); return; } user = u; var isPost = type == "op"; if (isPost) { post = await PostsRepository.getPostByIdAsync(targeti); } else { comment = await CommentsRepository.getCommentByIdAsync(targeti); } await base.OnParametersSetAsync(); } [Parameter] [Required] public string targetuserid { get; set; } [Parameter] [Required] public string threadid { get; set; } [Parameter] [Required] public string type { get; set; } [Parameter] [Required] public string board { get; set; } [Parameter] [Required] public string targetid { get; set; } }