public JsonResult AddMenu(int? parentNode, string pageName, string url,int?index)
        {
            var check = _menuRepository.GetMenuByCondition(pageName, url);

            if (check.Count() > 1)
            {
                return Json(new { result = false, msg = "修改失败,已存在相同的菜单!" }, JsonRequestBehavior.AllowGet);
            }
            var menu = new t_resources()
            {
                name = pageName,
                url = url,
                parentrid = parentNode,
                tindex=index
            };

            try
            {
              var result= _menuRepository.AddMenu(menu);
              if (result)
              {
                  return Json(new { result = true, msg = "" }, JsonRequestBehavior.AllowGet);
              }
              else
              {
                  return Json(new { result = false, msg = "操作失败!" }, JsonRequestBehavior.AllowGet);
              }
            }
            catch (Exception ex)
            {
                return Json(new { result = false, msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
        public bool UpdateMenu(t_resources menu)
        {
            dbContext.Set<t_resources>().Attach(menu);

            dbContext.Entry<t_resources>(menu).State = EntityState.Modified;

            return dbContext.SaveChanges() > 0;
        }
        public JsonResult DeleteMenu(int rid)
        {
            var menu = new t_resources()
            {
                rid=rid
            };

            try
            {
                var result = _menuRepository.DeleteMenu(menu);
                if (result)
                {
                    return Json(new { result = true, msg = "" }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return Json(new { result = false, msg = "操作失败!" }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                return Json(new { result = false, msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
 public bool AddMenu(t_resources menu)
 {
     dbContext.Entry<t_resources>(menu).State = EntityState.Added;
     return dbContext.SaveChanges() > 0;
 }