Some more comment fixes

This commit is contained in:
Slendy 2022-02-13 11:12:58 -06:00
commit 35d200502e
3 changed files with 9 additions and 9 deletions

View file

@ -37,14 +37,14 @@ public class SlotPageController : ControllerBase
}
[HttpGet("postComment")]
public async Task<IActionResult> PostComment([FromRoute] int id, [FromQuery] string msg)
public async Task<IActionResult> PostComment([FromRoute] int id, [FromQuery] string? msg)
{
User? user = this.database.UserFromWebRequest(this.Request);
if (user == null) return this.Redirect("~/login");
bool success = await this.database.PostComment(user, id, CommentType.Level, msg);
if (msg == null) return this.Redirect("~/slot/" + id);
if (!success) return this.NotFound();
await this.database.PostComment(user, id, CommentType.Level, msg);
return this.Redirect("~/slot/" + id);
}

View file

@ -35,25 +35,25 @@ public class UserPageController : ControllerBase
}
[HttpGet("rateComment")]
public async Task<IActionResult> RateComment([FromRoute] int id, [FromQuery] int commentId, [FromQuery] int rating)
public async Task<IActionResult> RateComment([FromRoute] int id, [FromQuery] int? commentId, [FromQuery] int? rating)
{
User? user = this.database.UserFromWebRequest(this.Request);
if (user == null) return this.Redirect("~/login");
await this.database.RateComment(user, commentId, rating);
await this.database.RateComment(user, commentId.GetValueOrDefault(), rating.GetValueOrDefault());
return this.Redirect("~/user/" + id + "#" + commentId);
}
[HttpGet("postComment")]
public async Task<IActionResult> PostComment([FromRoute] int id, [FromQuery] string msg)
public async Task<IActionResult> PostComment([FromRoute] int id, [FromQuery] string? msg)
{
User? user = this.database.UserFromWebRequest(this.Request);
if (user == null) return this.Redirect("~/login");
bool success = await this.database.PostComment(user, id, CommentType.Profile, msg);
if (msg == null) return this.Redirect("~/user/" + id);
if (!success) return this.NotFound();
await this.database.PostComment(user, id, CommentType.Profile, msg);
return this.Redirect("~/user/" + id);
}

View file

@ -62,7 +62,7 @@
</div>
</div>
}
@if(Model.CommentsEnabled){
@if(Model.CommentsEnabled && Model.User != null){
<div class="ui divider"></div>
<form class="ui reply form" action="@Url.RouteUrl(ViewContext.RouteData.Values)/postComment">
<div class="field">