示例#1
0
        public void AddComment(CreateCommentViewModel model)
        {
            _context.Comments.Add(new Comment
            {
                PostId = model.PostId,
                AuthorName = model.AuthorName,
                Content = model.Content
            });

            _context.SaveChanges();
        }
示例#2
0
        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 });
        }