예제 #1
0
        public async Task <bool> UnbindRole(Guid userRoleId)
        {
            var result   = false;
            var userRole = UserRoleDb.GetById(userRoleId);

            if (!userRole.IsNull())
            {
                result = await UserRoleDb.AsDeleteable().ExecuteCommandAsync() > 0;
            }

            return(result);
        }
예제 #2
0
        public async Task <bool> BindRoles(Guid userId, string[] roleIds)
        {
            bool result = false;

            await UserRoleDb.AsDeleteable().Where(ur => ur.UserId == userId).ExecuteCommandAsync();

            foreach (var roleId in roleIds)
            {
                var userRole = new UserRole()
                {
                    Id = Guid.NewGuid(), RoleId = roleId.ToGuid(), UserId = userId
                };
                result = await UserRoleDb.AsInsertable(userRole).ExecuteCommandAsync() > 0;
            }

            return(result);
        }