@page "/sys/report/{type}/{board}/{id}" @using System.ComponentModel.DataAnnotations @using System.Data @using ImageBoardServerApp.Auth @using ImageBoardServerApp.Data.Repository @inject AuthenticationStateProvider authStateProvider @inject IJSRuntime js Report @type#@id on /@board/ - BulletBoards Report @type#@id on /@board/ Select @foreach (var r in RulesConv.dict.Keys) { @RulesConv.dict[r] } @selectedItem Explain further (optional) Please login to report @code { private IEnumerable rules; private string selectedItem; private string explaination; [Parameter] [Required] public string type { get; set; } [Parameter] [Required] public string board { get; set; } [Parameter] [Required] public string id { get; set; } private async Task onReportClick() { if (selectedItem == null || selectedItem == "none") return; if (explaination == null) return; var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider; var user = await cauthStateProvder.GetAuthenticationStateAsync(); var usr = user.User; UserData foundusr = await UsersRepository.getUserByEmailRawAsync(usr.Identity.Name); if (foundusr == null) { return; } if (foundusr.TimeBanned != -1) { return; } foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds(); await UsersRepository.updateUserAsync(foundusr); int targetID = 0; if (type == "op") { var post = await PostsRepository.getPostByIdAsync(Int32.Parse(id)); targetID = post.User.UserID; } else { var comment = await CommentsRepository.getCommentByIdAsync(Int32.Parse(id)); targetID = comment.User.UserID; } ReportData reportData = new ReportData() { Type = type, ReportedCommentID = type == "op" ? null : Int32.Parse(id), ReportedPostID = type == "op" ? Int32.Parse(id) : null, UserReporterID = foundusr.UserID, UserReportedID = targetID, ReportReason = RulesConv.dict[RulesConv.dict2[selectedItem]], ReportExlaination = explaination }; List submittedReports = foundusr.RecivedReports; if (foundusr.RecivedReports != null) { foreach (var r in submittedReports) { if (r.ReportedPostID == reportData.ReportedPostID && r.ReportedCommentID == reportData.ReportedCommentID) return; } } await ReportsRepository.createReportAsync(reportData); js.InvokeVoidAsync("window.close"); } }