Exemple #1
0
        public async Task <IdentityResult> CreateAsync(TRole role, CancellationToken cancellationToken)
        {
            IdRole idRole = ToImmutable(role);
            var    result = await RoleStore.Ask(new RoleCommands.Create(idRole), TimeSpan.FromSeconds(_StandardTimeoutSeconds), cancellationToken);

            return(new IdentityResult());
        }
Exemple #2
0
        public async Task <IdentityResult> UpdateAsync(TRole role, CancellationToken cancellationToken)
        {
            var update = new IdRole(role.Id, role.Name, role.NameNormalized, Unique.String());
            var result = await RoleStore.Ask(new RoleCommands.Update(update), TimeSpan.FromSeconds(_StandardTimeoutSeconds), cancellationToken);

            return(new IdentityResult());
        }
Exemple #3
0
        public override int GetHashCode()
        {
            var hashCode = 2065429282;

            hashCode = hashCode * -1521134295 + IdRole.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(RoleName);

            return(hashCode);
        }
        }                                     //Key

        public override int GetHashCode()
        {
            unchecked
            {
                int result = IdRole.GetHashCode();
                result = (IdRole * 397) ^ IdPermission.GetHashCode();
                return(result);
            }
        }
        }                                    //Key

        public override int GetHashCode()
        {
            unchecked
            {
                int result = IdRole.GetHashCode();
                result = (IdRole * 397) ^ IdUserLogin.GetHashCode();
                return(result);
            }
        }
Exemple #6
0
 private TRole ToMutable(IdRole role)
 {
     return(new TRole
     {
         Id = role.Id,
         Name = role.Name,
         NameNormalized = role.NameNormalized,
         ConcurrencyStamp = role.ConcurrencyStamp
     });
 }
 public String ToString()
 {
     return("Community - Id " + ((Community != null) ? Community.Id.ToString() : "0") + " IdRole: " + IdRole.ToString());
 }
Exemple #8
0
        /// <summary>
        /// 创建新角色
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="name"></param>
        /// <param name="sex"></param>
        /// <returns></returns>
        private static async Task <BaseResponseData> CreateNewRole()//string sessionId, string name, int sex)
        {
            CreateRoleResult result = new CreateRoleResult();
            var account             = User.account;
            var sessionId           = User.sessionId;

            if (User.bytes == null)
            {
                result.Result = GameEnum.WsResult.ParamsError;
                return(result);
            }
            var data = await InitHelpers.GetPse().DeserializeAsync <CreateRoleReq>(User.bytes);

            var name = data.Name;
            var sex  = data.Sex;

            if (string.IsNullOrEmpty(name))
            {
                result.Result = GameEnum.WsResult.ParamsError;
                return(result);
            }
            var allRoles = await RoleListDataHelper.Instance.GetRoleListByAccountIdAsync(account.AccountID);

            if (allRoles != null)
            {
                if (account.RoleNumber >= 10)
                {
                    result.ErrorDesc = "角色数量过多,请删除部分角色再创建";
                    return(result);
                }
                //检查是否重名
                if (await IdRoleDataHelper.Instance.CheckIdRoleByRoleNameAsync(name))
                {
                    result.ErrorDesc = "角色名重复";
                    return(result);  //重名直接返回
                }
                //构造新角色
                UserRole user   = new UserRole(sex, name, account.AccountID);
                IdRole   idRole = new IdRole(user.Name, user.Id);

                await IdRoleDataHelper.Instance.SetIdRoleByRoleNameAsync(name, idRole);

                await RoleDataHelper.Instance.SetRoleByRoleIdAsync(user.Id, user);


                List <UserRole> roles = new List <UserRole>();
                roles.AddRange(allRoles);
                roles.Add(user);
                await RoleListDataHelper.Instance.UpdateRoleListByAccountIdAsync(account.AccountID, roles);

                await RoleDataHelper.Instance.UpdateRoleBySidAsync(sessionId, user);

                result.ErrorDesc = "";
                result.Name      = name;
                result.Sex       = sex;
                result.RoleId    = user.Id.ToString();
            }
            else
            {
                ///没有角色,新增一个
                //检查重名
                if (await IdRoleDataHelper.Instance.CheckIdRoleByRoleNameAsync(name))
                {
                    result.ErrorDesc = "角色名重复";
                    return(result);
                }
                //构造新角色
                UserRole user   = new UserRole(sex, name, account.AccountID);
                IdRole   idRole = new IdRole(user.Name, user.Id);


                await IdRoleDataHelper.Instance.SetIdRoleByRoleNameAsync(name, idRole);

                await RoleDataHelper.Instance.SetRoleByRoleIdAsync(user.Id, user);

                List <UserRole> roles = new List <UserRole>();
                roles.Add(user);

                await RoleListDataHelper.Instance.SetRoleListByAccountIdAsync(user.AccountId, roles);

                await RoleDataHelper.Instance.SetRoleBySidAsync(sessionId, user);

                result.ErrorDesc = "";
                result.Name      = name;
                result.Sex       = sex;
                result.RoleId    = user.Id.ToString();
            }
            return(result);
        }
Exemple #9
0
 public Update(IdRole role)
 {
     Role = role;
 }
Exemple #10
0
 public Create(IdRole role)
 {
     Role = role;
 }