public ActionResult PostComment(int postId, string name, string content) { var db = new BlogDb(@"Data Source=.\sqlexpress;Initial Catalog=Blog;Integrated Security=True"); Comment comment = new Comment {PostId = postId, Content = content, Name = name, Date = DateTime.Now}; db.AddComment(comment); return RedirectToAction("Post", new {pid = postId}); }
public ActionResult Comment(string name, string text, int postId) { var db = new BlogDb(_connectionString); Comment comment = new Comment { Date = DateTime.Now, Name = name, Text = text, PostId = postId }; db.AddComment(comment); return RedirectToAction("Post", new {postId = postId}); }