Exemplo n.º 1
0
        public ActionResult DeleteCO(int id)
        {
            using (BusinessDataBaseEntities db = new BusinessDataBaseEntities())
            {
                CommentOption c = db.CommentOptions.Where(x => x.CommentOptionID == id).FirstOrDefault <CommentOption>();
                db.CommentOptions.Remove(c);
                db.SaveChanges();

                return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public ActionResult AddOrEditCO(CommentOption c)
        {
            using (BusinessDataBaseEntities db = new BusinessDataBaseEntities())
            {
                if (c.CommentOptionID == 0)
                {
                    db.CommentOptions.Add(new CommentOption()
                    {
                        //CommentOptionID = c.CommentOptionID,
                        CommentOption1 = c.CommentOption1,
                    });
                    db.SaveChanges();

                    return(Json(new { success = true, message = "發布成功" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    db.Entry(c).State = EntityState.Modified;
                    db.SaveChanges();

                    return(Json(new { success = true, message = "修改成功" }, JsonRequestBehavior.AllowGet));
                }
            }
        }