Exemplo n.º 1
0
        public void AddUser(User user)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");
            AssertionConcern.AssertArgumentTrue(user.IsEnabled, "User is not enabled.");

            if (this.GroupMembers.Add(user.ToGroupMember()) && !this.IsInternalGroup)
            {
                DomainEventPublisher
                .Instance
                .Publish(new GroupUserAdded(
                             this.TenantId,
                             this.Name,
                             user.Username));
            }
        }
Exemplo n.º 2
0
        public void RemoveUser(User user)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");

            // not a nested remove, only direct member
            if (this.GroupMembers.Remove(user.ToGroupMember()) && !this.IsInternalGroup)
            {
                DomainEventPublisher
                .Instance
                .Publish(new GroupUserRemoved(
                             this.TenantId,
                             this.Name,
                             user.Username));
            }
        }
Exemplo n.º 3
0
        public bool IsMember(User user, GroupMemberService groupMemberService)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");
            AssertionConcern.AssertArgumentTrue(user.IsEnabled, "User is not enabled.");

            var isMember = this.GroupMembers.Contains(user.ToGroupMember());

            if (isMember)
            {
                isMember = groupMemberService.ConfirmUser(this, user);
            }
            else
            {
                isMember = groupMemberService.IsUserInNestedGroup(this, user);
            }

            return(isMember);
        }
Exemplo n.º 4
0
        public void AddUser(User user)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");
            AssertionConcern.AssertArgumentTrue(user.Enabled, "User is not enabled.");

            if (this.GroupMembers.Add(user.ToGroupMember()) && !this.IsInternalGroup())
            {
                DomainEventPublisher
                    .Instance
                    .Publish(new GroupUserAdded(
                            this.TenantId,
                            this.Name,
                            user.Username));
            }
        }
Exemplo n.º 5
0
        public void RemoveUser(User user)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");

            // not a nested remove, only direct member
            if (this.GroupMembers.Remove(user.ToGroupMember()) && !this.IsInternalGroup())
            {
                DomainEventPublisher
                    .Instance
                    .Publish(new GroupUserRemoved(
                            this.TenantId,
                            this.Name,
                            user.Username));
            }
        }
Exemplo n.º 6
0
        public bool IsMember(User user, GroupMemberService groupMemberService)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");
            AssertionConcern.AssertArgumentTrue(user.Enabled, "User is not enabled.");

            var isMember = this.GroupMembers.Contains(user.ToGroupMember());

            if (isMember)
            {
                isMember = groupMemberService.ConfirmUser(this, user);
            }
            else
            {
                isMember = groupMemberService.IsUserInNestedGroup(this, user);
            }

            return isMember;
        }