コード例 #1
0
		public ActionResult AddComment(Comment comment)
		{
			if (ModelState.IsValid)
			{
				comment.IPAddress = "127.0.0.1";
				var post = db.GetPostByID(comment.PostID);
				post.AddComment(comment);
				db.SavePost(post);
				return RedirectToAction("Details", new { slug = post.UrlSlug }); 
			}
			TempData["message"] = "Error adding comment";
			return RedirectToAction("Index");
		}
コード例 #2
0
ファイル: Post.cs プロジェクト: malevolence/malevolence.org
		public void AddComment(Comment comment)
		{
			comment.Post = this;
			Comments.Add(comment);
		}