public void AddComment(CreateCommentViewModel model) { _context.Comments.Add(new Comment { PostId = model.PostId, AuthorName = model.AuthorName, Content = model.Content }); _context.SaveChanges(); }
public IActionResult Comment( //[Bind(Prefix = "")] Guid postId, Guid threadId, CreateCommentViewModel model) { if (!ModelState.IsValid) return HttpBadRequest(); model.PostId = threadId; _postRepository.AddComment(model); return RedirectToRoute("thread", new { threadId = model.PostId }); }