Ejemplo n.º 1
0
        /// <summary>
        /// 给用户设置默认登录角色
        /// </summary>
        /// <returns></returns>

        public void SetDefaultRole(int userid)
        {
            Tright_User_Role_Da userrole = new Tright_User_Role_Da();

            if (userrole.Where(s => s.Userid == userid).Count() <= 0)
            {
                Tright_User_Role userolemodel = new Tright_User_Role()
                {
                    Roleid = 1,   //默认1为普通会员
                    Userid = userid
                };

                userrole.Insert(userolemodel);
            }
        }
        public IActionResult AddUserRoleMebmer(int userid, int roleid)
        {
            Tright_User_Role_Da userroleManage = new Tright_User_Role_Da();

            if (userroleManage.Select.Where(s => s.Role_Id == roleid && s.User_Id == userid).Count() > 0)
            {
                return(SuccessMessage("请不要反复添加!"));
            }

            Tright_User_Role model = new Tright_User_Role
            {
                Role_Id = roleid,
                User_Id = userid
            };

            userroleManage.Insert(model);

            return(SuccessMessage("添加成功!"));
        }