public ActionResult Insert()
 {
     AdminDanhMucModel tnew = new AdminDanhMucModel();
     dbFirstStepDataContext db = new dbFirstStepDataContext();
     ViewBag.DanhMuc = db.EntityDanhMucs.Where(p => p.IdRoot == null).ToList();
     return View(tnew);
 }
 public static void Edit(AdminDanhMucModel Banner)
 {
     dbFirstStepDataContext db = new dbFirstStepDataContext();
     EntityDanhMuc Faq = db.EntityDanhMucs.Where(p => p.Id == Banner.Id).First();
     Faq.TenDM = Banner.TieuDe;
     Faq.IdRoot = Banner.IdRoot;
     db.SubmitChanges();
 }
 public static AdminDanhMucModel LayModel(int Id)
 {
     AdminDanhMucModel Ban = new AdminDanhMucModel();
     dbFirstStepDataContext db = new dbFirstStepDataContext();
     EntityDanhMuc tnew = db.EntityDanhMucs.Where(p => p.Id == Id).First();
     Ban.Id = tnew.Id;
     Ban.IdRoot  = tnew.IdRoot;
     Ban.TieuDe = tnew.TenDM;
     return Ban;
 }
        public ActionResult Edit(AdminDanhMucModel DM, HttpPostedFileBase Anh)
        {
            try
            {

                AdminDanhMucModel.Edit(DM);
                return RedirectToAction("Index", "AdminDanhMuc");
            }
            catch
            {
                return RedirectToAction("Index", "Error");
            }
        }
        public ActionResult Insert(AdminDanhMucModel DM)
        {
            try
            {
                dbFirstStepDataContext db = new dbFirstStepDataContext();
                EntityDanhMuc ban = new EntityDanhMuc();
                ban.TenDM = DM.TieuDe;
                ban.IdRoot = DM.IdRoot;
                db.EntityDanhMucs.InsertOnSubmit(ban);
                db.SubmitChanges();

                return RedirectToAction("Index", "AdminDanhMuc");
            }
            catch
            {
                return RedirectToAction("Index", "Error");
            }
        }