public ActionResult ConfigRole(PropertyUserConfigRoleModel model) { JsonModel jm = new JsonModel(); IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); //获取要分配角色的物业用户 T_PropertyUser user = propertyUserBll.GetEntity(m => m.Id == model.userId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); // 新建用户角色关联表 List <R_PropertyUserRole> roles = new List <R_PropertyUserRole>(); if (model.ids != null) { //没有设置任何角色 则不执行循环操作 foreach (var id in model.ids) { R_PropertyUserRole item = new R_PropertyUserRole() { UserId = model.userId, RoleId = id }; roles.Add(item); } } //修改物业用户对应的角色集合 if (propertyUserBll.ConfigRole(user, roles)) { jm.Content = "物业用户 " + user.TrueName + " 分配角色"; } else { jm.Msg = "分配角色失败"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }