Ejemplo n.º 1
0
 public JsonResult UpdatePageAction(Models.PageActionModel model)
 {
     if (ModelState.IsValid && model.Id > 0)
     {
         IDAL.IPageActionRepository pageActionRepository = EnterRepository.GetRepositoryEnter().GetPageActionRepository;
         //判断权限名称是否已存在
         var result = pageActionRepository.LoadEntities(m => m.ActionCode == model.ActionCode.Trim()).FirstOrDefault();
         if (result != null && result.Id != model.Id)
         {
             return(Json(new
             {
                 state = "error",
                 message = "页面按钮代码已经存在了"
             }));
         }
         else
         {
             Model.PageAction pageAction = new Model.PageAction()
             {
                 ActionCode  = model.ActionCode,
                 ActionLevel = model.ActionLevel,
                 IsShow      = model.IsShow,
                 Name        = model.Name,
                 Id          = model.Id
             };
             pageActionRepository.Get(m => m.Id == model.Id);
             pageActionRepository.EditEntity(pageAction, new string[] { "ActionCode", "ActionLevel", "IsShow", "Name" });
             PublicFunction.AddOperation(1, string.Format("修改页面按钮"), string.Format("修改页面按钮=={0}==成功", model.Name));
             if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
             {
                 return(Json(new
                 {
                     state = "success",
                     message = "修改页面按钮成功"
                 }));
             }
             else
             {
                 PublicFunction.AddOperation(1, string.Format("修改页面按钮"), string.Format("修改页面按钮=={0}==失败", model.Name));
                 EnterRepository.GetRepositoryEnter().SaveChange();
                 return(Json(new
                 {
                     state = "error",
                     message = "修改页面按钮失败"
                 }));
             }
         }
     }
     else
     {
         return(Json(new
         {
             state = "error",
             message = "信息不完整"
         }));
     }
 }
Ejemplo n.º 2
0
 public JsonResult AddPageAction(Models.PageActionModel model)
 {
     if (ModelState.IsValid)
     {
         IDAL.IPageActionRepository pageActionRepository = EnterRepository.GetRepositoryEnter().GetPageActionRepository;
         //判断页面按钮代码是否已存在
         var result = pageActionRepository.LoadEntities(m => m.ActionCode == model.ActionCode.Trim()).FirstOrDefault();
         if (result == null)
         {
             pageActionRepository.AddEntity(new Model.PageAction()
             {
                 ActionCode  = model.ActionCode,
                 ActionLevel = model.ActionLevel,
                 IsShow      = model.IsShow,
                 Name        = model.Name
             });
             //添加下操作记录
             PublicFunction.AddOperation(1, string.Format("添加页面按钮"), string.Format("添加角色=={0}==页面按钮成功", model.Name));
             if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
             {
                 return(Json(new
                 {
                     state = "success",
                     message = "添加页面按钮成功"
                 }));
             }
             else
             {
                 PublicFunction.AddOperation(1, string.Format("添加页面按钮"), string.Format("添加页面按钮=={0}==失败", model.Name));
                 EnterRepository.GetRepositoryEnter().SaveChange();
                 return(Json(new
                 {
                     state = "error",
                     message = "添加页面按钮失败"
                 }));
             }
         }
         else
         {
             return(Json(new
             {
                 state = "error",
                 message = "页面按钮代码已经存在了"
             }));
         }
     }
     else
     {
         return(Json(new
         {
             state = "error",
             message = "信息不完整"
         }));
     }
 }