public async Task <IActionResult> Reply(ReplyToCommentInputModel inputModel, int id) { ApplicationUser user = await this.userManager.GetUserAsync(this.User); int?postId = this.commentsService.GetPostId(id); inputModel.PostId = postId; inputModel.ParentId = id; inputModel.AuthorId = user.Id; await this.commentsService.ReplyToComment(inputModel); return(this.RedirectToAction("SeePost", "Posts", new { Id = postId })); }
public async Task ReplyToComment(ReplyToCommentInputModel inputModel) { Comment comment = new Comment { Content = inputModel.Content, PostId = inputModel.PostId, AuthorId = inputModel.AuthorId, ParentId = inputModel.ParentId, }; await this.commentRepository.AddAsync(comment); await this.commentRepository.SaveChangesAsync(); }