public ActionResult DeleteConfirmed(decimal id)
        {
            TinTucThongBao tinTucThongBao = db.TinTucThongBaos.Find(id);

            db.TinTucThongBaos.Remove(tinTucThongBao);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "TinTucId,TieuDe,NoiDung,NgayDang,TaiKhoanId")] TinTucThongBao tinTucThongBao)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tinTucThongBao).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TaiKhoanId = new SelectList(db.TaiKhoans, "TaiKhoanId", "Username", tinTucThongBao.TaiKhoanId);
     return(View(tinTucThongBao));
 }
예제 #3
0
        public ActionResult Create([Bind(Include = "TinTucId,TieuDe,NoiDung,NgayDang,TaiKhoanId")] TinTucThongBao tinTuc)
        {
            if (ModelState.IsValid)
            {
                db.TinTucThongBaos.Add(tinTuc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TaiKhoanId = new SelectList(db.TaiKhoans, "TaiKhoanId", "Username");
            return(View(tinTuc));
        }
 // GET: TinTucThongBaos/Details/5
 public ActionResult Details(decimal id)
 {
     if (!UserManager.Authenticated)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         TinTucThongBao tinTucThongBao = db.TinTucThongBaos.Find(id);
         if (tinTucThongBao == null)
         {
             return(HttpNotFound());
         }
         return(View(tinTucThongBao));
     }
 }
 // GET: TinTucThongBaos/Edit/5
 public ActionResult Edit(decimal id)
 {
     if (!UserManager.Authenticated)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     else
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         TinTucThongBao tinTucThongBao = db.TinTucThongBaos.Find(id);
         if (tinTucThongBao == null)
         {
             return(HttpNotFound());
         }
         ViewBag.TaiKhoanId = new SelectList(db.TaiKhoans, "TaiKhoanId", "Username", tinTucThongBao.TaiKhoanId);
         return(View(tinTucThongBao));
     }
 }