public async Task <ActionResult <bool> > EditComment(CommentEditInputModel input) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); await this.commentsService.EditCommentAsync(input.CommentNumber, userId, input.CommentInfo); return(true); }
public async Task <IActionResult> Edit(CommentEditInputModel 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); } var isValidContent = true; if (string.IsNullOrEmpty(input.Content) || string.IsNullOrWhiteSpace(input.Content)) { isValidContent = false; this.TempData["CommentContentError"] = ContentLengthError; } else if (input.Content.Length < AttributesConstraints.CommentContentMinLength || input.Content.Length > AttributesConstraints.CommentContentMaxLength) { isValidContent = false; this.TempData["CommentContentError"] = ContentLengthError; } if (!this.ModelState.IsValid || !isValidComment || !isValidContent) { return(this.RedirectToAction("Details", "Recipes", new { id = input.RecipeId })); } if (input.ReplyId == null) { await this.commentsService.EditAsync(input.CommentId, input.Content); } else { await this.commentsService.EditReplyToCommentAsync(input.ReplyId, input.Content); } return(this.RedirectToAction("Details", "Recipes", new { id = input.RecipeId })); }