public ActionResult DeleteConfirmed(long id) { t_news_category t_news_category = db.t_news_category.Find(id); db.t_news_category.Remove(t_news_category); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(long id = 0) { t_news_category t_news_category = db.t_news_category.Find(id); if (t_news_category == null) { return(HttpNotFound()); } return(View(t_news_category)); }
public ActionResult Edit(long id, t_news_category t_news_category) { if (ModelState.IsValid) { t_news_category news_category = db.t_news_category.Find(id); using (db) { news_category.category_date = DateTime.Now; news_category.category_title = t_news_category.category_title; news_category.user_id = (from table in db.users where table.username == User.Identity.Name select table.id_user).FirstOrDefault(); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_news_category)); }
public ActionResult Create(t_news_category t_news_category) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_news_category.Create(); create.category_date = DateTime.Now; create.category_title = t_news_category.category_title; create.user_id = (from table in db.users where table.username == User.Identity.Name select table.id_user).FirstOrDefault(); db.t_news_category.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(t_news_category)); }