コード例 #1
0
        //[InlineData("abd", true)]
        public void AnyOrganizationUserWithSharedUserId_Test(int organizationUserId)
        {
            SetupOrganizationUsersDbSet(new List <OrganizationUserEntity>
            {
                new OrganizationUserEntity
                {
                    OrganizationId           = 22,
                    LastLoginAt              = 100000010,
                    OrganizationUserEntityId = 22,
                    UserId       = "abc",
                    Organization = new OrganizationEntity()
                }
            });

            var res = organizationUserRepository.AnyOrganizationUserWithSharedUserId(organizationUserId);

            Assert.NotNull(res);
        }
コード例 #2
0
        public Result <AnyOrganizationUserWithSharedUserId> DeleteOrganizationUser(int?organizationUserId, int?userType, int?organizationId)
        {
            if (!organizationId.HasValue)
            {
                return(new Result <AnyOrganizationUserWithSharedUserId>(OrganizationUserServiceErrors.InvalidOrganizationId()));
            }
            if (!userType.HasValue)
            {
                return(new Result <AnyOrganizationUserWithSharedUserId>(OrganizationUserServiceErrors.InvalidUserTypeId()));
            }
            if (!organizationUserId.HasValue)
            {
                return(new Result <AnyOrganizationUserWithSharedUserId>(OrganizationUserServiceErrors.InvalidOrganizationUserId()));
            }
            if (!organizationUserRepository.OrganizationUserExists(organizationUserId.Value, organizationId.Value))
            {
                return(new Result <AnyOrganizationUserWithSharedUserId>(OrganizationUserServiceErrors.NotFoundError()));
            }

            var deletedAt = organizationUserRepository.DeleteOrganizationUser(organizationUserId.Value, userType.Value, organizationId.Value);

            groupRepository.DisassociateOrganizationUserFromAllGroups(new DisassociateOrganizationUserFromAllGroupsCommand
            {
                OrganizationId     = organizationId.Value,
                OrganizationUserId = organizationUserId.Value
            });

            var isLastUserIdRelationship = organizationUserRepository.AnyOrganizationUserWithSharedUserId(organizationUserId.Value);

            isLastUserIdRelationship.DeletedAt = deletedAt;

            var publishResult = PublishDeleteOrganizationUser(
                organizationUserId.Value,
                userType.Value,
                deletedAt,
                organizationId.Value);

            return(new Result <AnyOrganizationUserWithSharedUserId>(isLastUserIdRelationship));
        }