public async Task <IActionResult> Delete(CommentDeleteInputModel input) { var userId = this.userManager.GetUserId(this.User); var isValidComment = false; if (input.ReplyId == null) { isValidComment = this.commentsService.IsCommentUser(userId, input.CommentId); } else { isValidComment = this.commentsService.IsReplyUser(userId, input.ReplyId); } if (!this.ModelState.IsValid || !isValidComment) { return(this.RedirectToAction("Details", "Recipes", new { id = input.RecipeId })); } if (input.ReplyId == null) { await this.commentsService.DeleteAsync(input.CommentId); } else { this.commentsService.DeleteReplyFromComment(input.ReplyId); } return(this.RedirectToAction("Details", "Recipes", new { id = input.RecipeId })); }
public async Task <ActionResult <bool> > DeleteComment(CommentDeleteInputModel input) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); await this.commentsService.DeleteCommentAsync(input.CommentNumber, userId); return(true); }