Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Comment([Bind(Include = "postID, name, message")] int postId, string name, string message)
- {
- using (var database = new BlogDbContext())
- {
- Publication publication = database.Publications.Find(postId);
- Comment comment = new Comment();
- comment.PostID = postId;
- comment.CreatedDate = DateTime.Now;
- comment.Name = name;
- comment.Body = message;
- comment.Publications = publication;
- database.Comments.Add(comment);
- database.SaveChanges();
- return RedirectToAction("ReadPost");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement