예제 #1
0
        //异步提交评论
        public JsonResult SubComment()
        {
            //先判断登录
            int?userId = WebHelper.GetUserIdInSession();

            if (userId == null || userId.Value <= 0)
            {
                return(Json(new { Status = "error", Data = "" }, JsonRequestBehavior.AllowGet));
            }
            //新增评论
            ChapterCommentBLL commentBll = new ChapterCommentBLL();
            DateTime          now        = DateTime.Now;
            ChapterComment    comment    = new ChapterComment();

            comment.ChapterId = Convert.ToInt32(Request["chapterId"]);
            comment.Comment   = Request["comment"];
            comment.PostTime  = now;
            comment.UserId    = userId.Value;
            int  id   = commentBll.AddComment(comment);
            User user = new UserBLL().GetById(userId.Value);

            return(Json(new { Status = "ok",
                              Id = id,
                              Time = now.ToString("yyyy-MM-ddTHH:mm:ss"),  //2016-05-16T22:34:28
                              UserName = user.UserName, }, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult CreateChapterComment(int chapterId)
        {
            var comment = new ChapterComment()
            {
                ChapterId = chapterId
            };

            return(PartialView("_CreateOrEditChapterComment", comment));
        }
예제 #3
0
 public ActionResult EditChapterComment(ChapterComment chaptercomment)
 {
     if (ModelState.IsValid)
     {
         _commentRepo.InsertOrUpdateChapterComments(chaptercomment);
         _commentRepo.Save();
         return(new HttpStatusCodeResult(HttpStatusCode.OK));
     }
     return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
 }
예제 #4
0
        private ChapterComment RowToComment(DataRow row)
        {
            ChapterComment comment = new ChapterComment();

            comment.ChapterId = (int)row["ChapterId"];
            comment.Comment   = (string)row["Comment"];
            comment.Id        = (int)row["Id"];
            comment.PostTime  = (DateTime)row["PostTime"];
            comment.UserId    = (int)row["UserId"];
            comment.UserName  = (string)row["UserName"];
            return(comment);
        }
예제 #5
0
        //新增一条评论
        public object AddComment(ChapterComment comment)
        {
            string sql = "insert ChapterComments(Comment,PostTime,ChapterId,UserId) values(@Comment,@PostTime,@ChapterId,@UserId);select  @@Identity;";

            return(MySqlHelper.ExecuteScalar(sql, new MySqlParameter[]
            {
                new MySqlParameter("@Comment", comment.Comment),
                new MySqlParameter("@PostTime", comment.PostTime),
                new MySqlParameter("@ChapterId", comment.ChapterId),
                new MySqlParameter("@UserId", comment.UserId),
            }));
        }
 public void InsertOrUpdate(ChapterComment chaptercomment)
 {
     if (chaptercomment.Id == default(int))
     {
         // New entity
         context.ChapterComments.Add(chaptercomment);
     }
     else
     {
         // Existing entity
         context.Entry(chaptercomment).State = EntityState.Modified;
     }
 }
예제 #7
0
 //新增一条评论
 public int AddComment(ChapterComment comment)
 {
     return(Convert.ToInt32(commentDal.AddComment(comment)));
 }