コード例 #1
0
        public ActionResult DeleteConfirmed(long id)
        {
            tb_comments tb_comments = db.tb_comments.Find(id);

            db.tb_comments.Remove(tb_comments);
            db.SaveChanges();
            return(Redirect("Index?page=1"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "comment_id,user_id,article_id,comment_like_count,comment_date,comment_content,parent_comment_id")] tb_comments tb_comments)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tb_comments).State = EntityState.Modified;
         db.SaveChanges();
         return(Redirect("Index?page=1"));
     }
     ViewBag.user_id = new SelectList(db.tb_users, "user_id", "user_ip", tb_comments.user_id);
     return(View(tb_comments));
 }
コード例 #3
0
        // GET: Comments/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tb_comments tb_comments = db.tb_comments.Find(id);

            if (tb_comments == null)
            {
                return(HttpNotFound());
            }
            return(View(tb_comments));
        }
コード例 #4
0
        // GET: Comments/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tb_comments tb_comments = db.tb_comments.Find(id);

            if (tb_comments == null)
            {
                return(HttpNotFound());
            }
            ViewBag.user_id = new SelectList(db.tb_users, "user_id", "user_ip", tb_comments.user_id);
            return(View(tb_comments));
        }
コード例 #5
0
        // GET: Comments/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tb_comments tb_comments = db.tb_comments.Find(id);

            if (tb_comments == null)
            {
                return(HttpNotFound());
            }
            db.tb_comments.Remove(tb_comments);
            db.SaveChanges();
            return(Redirect("Index?page=1"));
        }
コード例 #6
0
        //添加评论
        public static void AddComment(string user_id, string article_id, string comment_content)
        {
            tb_comments comments = new tb_comments();

            if (user_id != null)
            {
                comments.user_id = Convert.ToInt32(user_id);
            }
            else
            {
                comments.user_id = null;
            }
            comments.article_id         = Convert.ToInt32(article_id);
            comments.comment_content    = comment_content;
            comments.comment_date       = DateTime.Now;
            comments.comment_like_count = 0;
            db.tb_comments.Add(comments);
            db.SaveChanges();
        }