public ActionResult AddComment(string content, string userId, string ariticleId, string comment_temp) { CommentRepository cr = new CommentRepository(); UserRepository ur = new UserRepository(); string result = ""; if (comment_temp != "null") { string[] array = comment_temp.Split('#'); int id = Int32.Parse(array[0]); string firstUserId = array[1]; Comment c = cr.FindByID(id); User u = ur.FindByID(userId); User firstUser = ur.FindByID(firstUserId); c.Isleaf = 1; cr.Update(c); Comment comment = new Comment(); comment.UserId = userId; comment.AriticleId = ariticleId; comment.Content = content; comment.NickName = u.NickName; comment.FirstNickName = firstUser.NickName; comment.Pid = id; comment.Isleaf = 0; comment.CommentTime = DateTime.Now; cr.Add(comment); result = ""; result = JsonConvert.SerializeObject(comment); } else { User u = ur.FindByID(userId); Comment comment = new Comment(); comment.UserId = userId; comment.Content = content; comment.CommentTime = DateTime.Now; comment.AriticleId = ariticleId; comment.Pid = 0; comment.Isleaf = 0; comment.Level = 1; comment.NickName = u.NickName; comment.FirstNickName = null; cr.Add(comment); result = ""; result = JsonConvert.SerializeObject(comment); ; } return Content(result); }