Esempio n. 1
0
        public ActionResult ConfigRole(CompanyUserConfigRoleModel model)
        {
            JsonModel jm = new JsonModel();

            ICompanyUserBLL companyUserBll = BLLFactory <ICompanyUserBLL> .GetBLL("CompanyUserBLL");

            //获取要分配角色的物业总公司用户
            T_CompanyUser user = companyUserBll.GetEntity(m => m.Id == model.userId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
            // 新建物业总公司用户角色关联表
            List <R_CompanyUserRole> roles = new List <R_CompanyUserRole>();

            if (model.ids != null)
            {
                //没有设置任何角色 则不执行循环操作
                foreach (var id in model.ids)
                {
                    R_CompanyUserRole item = new R_CompanyUserRole()
                    {
                        UserId = model.userId, RoleId = id
                    };
                    roles.Add(item);
                }
            }

            //修改物业用户对应的角色集合
            if (companyUserBll.ConfigRole(user, roles))
            {
                jm.Content = "物业用户 " + user.TrueName + " 分配角色";
            }
            else
            {
                jm.Msg = "分配角色失败";
            }

            return(Json(jm, JsonRequestBehavior.AllowGet));
        }