public ActionResult ConfigRole(int id) { // 创建平台用户角色模型 PlatformUserRoleModel userRoleModel = new PlatformUserRoleModel(); // 获取指定id的平台用户模型 IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL"); T_PlatformUser platformUser = platformUserBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); userRoleModel.User = new PlatformUserModel() { UserId = platformUser.Id, UserName = platformUser.UserName, TrueName = platformUser.TrueName, Tel = platformUser.Tel, Phone = platformUser.Phone, Memo = platformUser.Memo, Email = platformUser.Email }; // 获取所有平台角色 IPlatformRoleBLL platformRoleBll = BLLFactory <IPlatformRoleBLL> .GetBLL("PlatformRoleBLL"); //排序 var sortModel = this.SettingSorting("Id", false); var roleList = platformRoleBll.GetList(p => p.IsSystem == ConstantParam.USER_ROLE_DEFAULT, sortModel.SortName, sortModel.IsAsc).ToList(); userRoleModel.RoleList = roleList; //获取该用户已分配的角色id的集合 userRoleModel.RoleIds = platformUser.PlatformUserRoles.Select(m => m.RoleId).ToList(); return(View(userRoleModel)); }
public ActionResult ScanRole(int id) { // 创建平台用户角色模型 PlatformUserRoleModel userRoleModel = new PlatformUserRoleModel(); IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL"); // 根据指定id值获取实体对象 var userInfo = platformUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); userRoleModel.User = new PlatformUserModel() { UserName = userInfo.UserName, UserId = userInfo.Id, TrueName = userInfo.TrueName }; // 获取用户已分配的角色id列表 var selectedRoleList = userInfo.PlatformUserRoles.Select(m => m.RoleId).ToList(); userRoleModel.RoleIds = selectedRoleList; // 获取所有平台角色 IPlatformRoleBLL platformRoleBll = BLLFactory <IPlatformRoleBLL> .GetBLL("PlatformRoleBLL"); //排序 var sortModel = this.SettingSorting("Id", false); var roleList = platformRoleBll.GetList(p => true, sortModel.SortName, sortModel.IsAsc).ToList(); userRoleModel.RoleList = roleList; return(View(userRoleModel)); }