public JsonResult RolePageActionDesc(int id = 0) { IDAL.IAuthoryToPageRepository repository = EnterRepository.GetRepositoryEnter().GetAuthoryToPageRepository; List <Model.AuthoryToPage> authoryPageList = repository.LoadEntities(m => m.AuthoryId == id).ToList(); return(Json(new { state = "success", authoryPageList })); }
public JsonResult UpdatePageAction(int id, List <Models.RolePageModel> model) { JavaScriptSerializer serializer = new JavaScriptSerializer(); IDAL.IAuthoryToPageRepository repository = EnterRepository.GetRepositoryEnter().GetAuthoryToPageRepository; foreach (var item in model) { AuthorDesign.Model.AuthoryToPage authoryPageModel = repository.LoadEntities(m => m.AuthoryId == id && m.PageId == item.PageId).FirstOrDefault(); if (authoryPageModel == null) { authoryPageModel = new Model.AuthoryToPage(); authoryPageModel.AuthoryId = id; authoryPageModel.PageId = item.PageId; authoryPageModel.ActionList = serializer.Serialize(item.ActionList); if (item.ActionList != null && item.ActionList.Count() > 0) { if (item.ActionList.Where(m => m.actionChecked == 1).Count() == 0) { authoryPageModel.IsShow = (byte)0; } else { authoryPageModel.IsShow = (byte)1; } } else { authoryPageModel.IsShow = (byte)0; } repository.AddEntity(authoryPageModel); } else { authoryPageModel.AuthoryId = id; authoryPageModel.PageId = item.PageId; authoryPageModel.ActionList = serializer.Serialize(item.ActionList); if (item.ActionList != null && item.ActionList.Count() > 0) { if (item.ActionList.Where(m => m.actionChecked == 1).Count() == 0) { authoryPageModel.IsShow = (byte)0; } else { authoryPageModel.IsShow = (byte)1; } } else { authoryPageModel.IsShow = (byte)0; } } } PublicFunction.AddOperation(2, string.Format("编辑角色页面按钮"), string.Format("编辑角色页面按钮成功")); if (EnterRepository.GetRepositoryEnter().SaveChange() > 0) { //将管理员对应按钮表将 角色Id对应的角色页面按钮 IsShow为0的页面 删除 EnterRepository.GetRepositoryEnter().GetAdminToPageRepository.DeleteByAuthoryId(id); return(Json(new { state = "success", message = "编辑角色页面按钮成功" })); } else { PublicFunction.AddOperation(2, string.Format("编辑角色页面按钮"), string.Format("编辑角色页面按钮失败")); EnterRepository.GetRepositoryEnter().SaveChange(); return(Json(new { state = "fail", message = "编辑角色页面按钮失败" })); } }