public ActionResult SaveFunctionInfoToRole(RoleFunctionInfoTreeModel model) { InkeyResult result = new InkeyResult(); this._authManagerService.SaveAuthFunctionInfoToRole(model); return(Json(result)); }
public void SaveAuthFunctionInfoToRole(RoleFunctionInfoTreeModel model) { using (var scope = AutoEfRepositoryFactory.GetEfRepositoryFactory(DataSources.DataSource_ItAdmin).CreateReadWriteContextScope()) { var roleInfo = this._efAuthRoleInfoRepository.Table.Where(g => g.Id == model.RoleId).FirstOrDefault(); var appFuncs = roleInfo.AuthFunctionInfos.Where(func => func.AppId == model.AppId).ToList(); foreach (var item in appFuncs) { roleInfo.AuthFunctionInfos.Remove(item); } List <AuthFunctionInfoEntity> roleFuncs = new List <AuthFunctionInfoEntity>(); Dictionary <Guid, AuthFunctionInfoEntity> added = new Dictionary <Guid, AuthFunctionInfoEntity>(); foreach (var item in model.FunctionInfos) { var func = this._efAuthFunctionInfoRepository.GetById(item.Id); var parents = GetALLParents(func, added); roleFuncs.Add(func); roleFuncs.AddRange(parents); } roleInfo.AuthFunctionInfos.AddRange(roleFuncs); this._efAuthRoleInfoRepository.Update(roleInfo); scope.SaveChanges(); } }
private static string ReAppear(RoleFunctionInfoTreeModel model) { StringBuilder sb = new StringBuilder(); if (model.FunctionInfos.Count == 0) { sb.Append("<!--no data-->"); return(sb.ToString()); } sb.AppendLine("<table id=\"rtree_" + model.AppId + "\" appId=\"" + model.AppId + "\" cellpadding=\"0\" cellspacing=\"0\" width=\"98%\">"); ReAppearTr(model.AddedFunctionInfos, model.FunctionInfos, sb); sb.AppendLine("</table>"); return(sb.ToString()); }
public static MvcHtmlString RoleTree(this HtmlHelper helper, RoleFunctionInfoTreeModel model) { var htmlString = ReAppear(model); return(new MvcHtmlString(htmlString)); }