Beispiel #1
0
 public JsonResult UpdatePageMenu(Models.PageMenuModel model)
 {
     if (ModelState.IsValid && model.Id > 0)
     {
         if (model.Id == model.PId)
         {
             return(Json(new { state = "error", message = "不能讲自己作为自己的父类" }));
         }
         IDAL.IPageMenuRepository pageMenuRepository = EnterRepository.GetRepositoryEnter().GetPageMenuRepository;
         var result = pageMenuRepository.LoadEntities(m => m.Name == model.Name.Trim()).FirstOrDefault();
         if (result != null && result.Id != model.Id)
         {
             return(Json(new {
                 state = "error",
                 message = "页面名称已经存在了"
             }));
         }
         else
         {
             Model.PageMenu pageMenu = new Model.PageMenu()
             {
                 Ico      = model.Ico,
                 IsShow   = model.IsShow,
                 Name     = model.Name,
                 OrderNum = model.OrderNum,
                 PageUrl  = model.PageUrl,
                 PId      = model.PId,
                 Id       = model.Id
             };
             pageMenuRepository.Get(m => m.Id == model.Id);
             pageMenuRepository.EditEntity(pageMenu, new string[] { "Ico", "IsShow", "Name", "OrderNum", "PageUrl", "PId" });
             PublicFunction.AddOperation(1, string.Format("修改页面"), string.Format("修改页面=={0}==成功", model.Name));
             if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
             {
                 CacheHelper.RemoveCache("SuperAdminMenuList");
                 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 = "信息不完整"
         }));
     }
 }
 public JsonResult UpdatePageMenu(Models.PageMenuModel model)
 {
     if (ModelState.IsValid && model.Id > 0) {
         if (model.Id == model.PId) {
             return Json(new { state = "error", message = "不能讲自己作为自己的父类" });
         }
         IDAL.IPageMenuRepository pageMenuRepository = EnterRepository.GetRepositoryEnter().GetPageMenuRepository;
         var result = pageMenuRepository.LoadEntities(m => m.Name == model.Name.Trim()).FirstOrDefault();
         if (result != null && result.Id != model.Id) {
             return Json(new {
                 state = "error",
                 message = "页面名称已经存在了"
             });
         }
         else {
             Model.PageMenu pageMenu = new Model.PageMenu() {
                 Ico = model.Ico,
                 IsShow = model.IsShow,
                 Name = model.Name,
                 OrderNum = model.OrderNum,
                 PageUrl = model.PageUrl,
                 PId = model.PId,
                 Id = model.Id
             };
             pageMenuRepository.Get(m => m.Id == model.Id);
             pageMenuRepository.EditEntity(pageMenu, new string[] { "Ico", "IsShow", "Name", "OrderNum", "PageUrl", "PId" });
             PublicFunction.AddOperation(1, string.Format("修改页面"), string.Format("修改页面=={0}==成功", model.Name));
             if (EnterRepository.GetRepositoryEnter().SaveChange() > 0) {
                 CacheHelper.RemoveCache("SuperAdminMenuList");
                 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 = "信息不完整"
         });
     }
 }