public ActionResult ThemMoi(DanhMuc danhmuc,FormCollection collection,string luu)
 {
     if (ModelState.IsValid)
     {
         int idDanhMucCha = int.Parse(collection["IdDanhMucCha"]);
         var danhmuccha = db.DanhMucs.SingleOrDefault(d => d.IdDanhMuc == idDanhMucCha);
         danhmuc.DanhMucCha = danhmuccha;
         db.DanhMucs.Add(danhmuc);
         db.SaveChanges();
         if ("Lưu và đóng".Equals(luu, StringComparison.OrdinalIgnoreCase))
         {
             return RedirectToAction("Index");
         }
         if ("Lưu và tạo mới".Equals(luu, StringComparison.OrdinalIgnoreCase))
         {
             return RedirectToAction("ThemMoi");
         }
     }
     ViewBag.IdDanhMucCha = new SelectList(DropdownListDanhMuc(0), "Value", "Text");
     return View(danhmuc);
 }
        public ActionResult Sua(DanhMuc danhmuc, FormCollection collection)
        {
            if (!Models.User.CurrentUser.Quyen.CoChucNang("sua_danh_muc"))
            {
                return RedirectToAction("Error", "Admin");
            }
            if (ModelState.IsValid)
            {
                db.Entry(danhmuc).State = EntityState.Modified;
                db.SaveChanges();

                int idDanhMucCha = int.Parse(collection["IdDanhMucCha"]);
                var danhmuccha = db.DanhMucs.SingleOrDefault(d => d.IdDanhMuc == idDanhMucCha);
                var dm = db.DanhMucs.SingleOrDefault(d => d.IdDanhMuc == danhmuc.IdDanhMuc);
                dm.DanhMucCha = danhmuccha;
                db.Entry(dm).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.IdDanhMucCha = new SelectList(DropdownListDanhMuc(danhmuc.IdDanhMuc), "Value", "Text",danhmuc.DanhMucCha.IdDanhMuc);
            return View(danhmuc);
        }