public async Task <IActionResult> Comment(PostCommentViewModel vm) { if (ModelState.IsValid) { var user = await _userHelper.GetUserByEmailAsync(User.Identity.Name); if (user == null) { return(NotFound()); } var post = await _postRepository.GetPostByIdAsync(vm.PostId); if (post == null) { return(NotFound()); } var comment = new PostComment { Name = vm.Name, Body = vm.Body, Post = post }; comment.Owner = user; comment.Date = DateTime.UtcNow; await _postRepository.AddCommentAsync(comment); return(RedirectToAction(nameof(Details), new { id = comment.Post.Id })); } return(View(vm)); }