public ActionResult DeleteConfirmed(int id)
        {
            G3_HealthEducation table = db.G3_HealthEducation.Find(id);

            db.G3_HealthEducation.Remove(table);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Details_other(int id = 0)
        {
            G3_HealthEducation table = db.G3_HealthEducation.Find(id);

            if (table == null)
            {
                return(HttpNotFound());
            }
            return(View(table));
        }
        public ActionResult Edit(int id = 0)
        {
            G3_HealthEducation table = db.G3_HealthEducation.Find(id);

            if (table == null || table.userId != User.Identity.Name)
            {
                return(HttpNotFound());
            }
            ViewBag.Message = "編輯文章";
            return(View(table));
        }
 public ActionResult Edit(G3_HealthEducation table)
 {
     if (ModelState.IsValid)
     {
         table.userId          = User.Identity.Name;
         table.Date            = DateTime.Now;
         db.Entry(table).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table));
 }
        public ActionResult Create(G3_HealthEducation table)
        {
            if (ModelState.IsValid)
            {
                table.userId = User.Identity.Name;
                table.Date   = DateTime.Now;
                db.G3_HealthEducation.Add(table);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(table));
        }
        public ActionResult Details(int id = 0)
        {
            G3_HealthEducation table = db.G3_HealthEducation.Find(id);

            if (table == null)
            {
                return(HttpNotFound());
            }
            else if (table.userId != User.Identity.Name)
            {
                return(RedirectToAction("Details_other", new { id = table.Id }));
            }
            return(View(table));
        }