/// <summary> /// 更新记录,在模块管理中修改模块节点时进行调用此函数 /// 以更新对应的角色匹配节点信息 /// </summary> /// <param name="oldEntity"></param> /// <param name="newEntity"></param> /// <returns></returns> internal int Update(ModuleNavigationModel oldEntity, ModuleNavigationModel newEntity) { List <RoleMatchModuleModel> mdls = this.irep.Entities.Where(e => e.ModuleNavPrimaryKey == oldEntity.PrimaryKey).ToList(); int record = UpdateData(newEntity, mdls); if (record == 0) { mdls = this.irep.Entities.Where(e => e.AssemblyName == oldEntity.AssemblyName && e.ModuleName == oldEntity.ModuleName && e.CtrlName == oldEntity.CtrlName).ToList(); record = UpdateData(newEntity, mdls); } return(record); }
private NavMenuModel CreateNavMenuModel(NavMenuModel mdl, ModuleNavigationModel nav, List <ModuleNavigationModel> navMdls) { mdl = new NavMenuModel() { Name = nav.ModuleName, Text = nav.ModuleText, AtLevel = nav.AtLevel, Item = nav, Childrens = navMdls }; return(mdl); }
private OpResult Add(ModuleNavigationModel entity) { int record = 0; if (entity == null) { return(OpResult.SetSuccessResult("ModuleNavigationModel entity can't be null", false)); } SetPrimaryPropertyValue(entity); if (!irep.IsExist(e => e.PrimaryKey == entity.PrimaryKey)) { record += irep.Insert(entity); } return(OpResult.SetSuccessResult("新增模块数据成功", record > 0, entity.Id_Key)); }
private OpResult Delete(ModuleNavigationModel entity) { if (entity == null) { return(OpResult.SetSuccessResult("ModuleNavigationModel entity can't be null", false)); } SetPrimaryPropertyValue(entity); int record = irep.Delete(r => r.PrimaryKey == entity.PrimaryKey); if (record > 0) { //删除角色与模块匹配列表中对应的记录 rm.MatchModuleHandler.Delete(entity.PrimaryKey); } return(OpResult.SetSuccessResult("删除模块数据成功", record > 0)); }
public OpResult Store(ModuleNavigationModel entity, ModuleNavigationModel oldEntity, string opType) { OpResult result = OpResult.SetSuccessResult("待进行操作", false); if (opType == "add") { result = Add(entity); } else if (opType == "delete") { result = Delete(entity); } else if (opType == "edit") { result = Update(oldEntity, entity); } return(result); }
private int UpdateData(ModuleNavigationModel newEntity, List <RoleMatchModuleModel> mdls) { int record = 0; if (mdls != null && mdls.Count > 0) { mdls.ForEach(m => { m.ModuleName = newEntity.ModuleName; m.ModuleText = newEntity.ModuleText; m.ActionName = newEntity.ActionName; m.CtrlName = newEntity.CtrlName; m.AssemblyName = newEntity.AssemblyName; SetPrimaryPropertyValue(m); record += irep.Update(u => u.Id_Key == m.Id_Key, m); }); } return(record); }
public OpResult Update(ModuleNavigationModel oldEntity, ModuleNavigationModel mdl) { if (mdl == null) { return(OpResult.SetSuccessResult("mdl can't be null", false)); } int record = 0; SetPrimaryPropertyValue(oldEntity); SetPrimaryPropertyValue(mdl); //1.更新自身记录 record = irep.Update(u => u.PrimaryKey == oldEntity.PrimaryKey, mdl); if (record > 0) { record += UpdateChildrenParentModuleTexts(record, oldEntity.ModuleText, mdl.ModuleText); //修改角色匹配模块记录中对应的信息 record += rm.MatchModuleHandler.Update(oldEntity, mdl); } return(OpResult.SetSuccessResult("修改成功!", record > 0)); }
public JsonResult SaveModuleNavData(ModuleNavigationModel moduleNav, ModuleNavigationModel oldModuleNav, string opType) { var result = AuthenService.ModuleManager.Store(moduleNav, oldModuleNav, opType); return(Json(result)); }
private void SetPrimaryPropertyValue(ModuleNavigationModel mdl) { mdl.PrimaryKey = string.Format("{0}&{1}&{2}&{3}", mdl.AssemblyName, mdl.ModuleName, mdl.CtrlName, mdl.ActionName); }