void RegisterAdministratorFor(Tenant tenant, FullName administorName, EmailAddress emailAddress, PostalAddress postalAddress, Telephone primaryTelephone, Telephone secondaryTelephone)
        {
            var invitation = tenant.OfferRegistrationInvitation("init").OpenEnded();

            var strongPassword = new PasswordService().GenerateStrongPassword();

            var admin =
                tenant.RegisterUser(
                    invitation.InvitationId,
                    "admin",
                    strongPassword,
                    Enablement.IndefiniteEnablement(),
                    new Person(
                        tenant.TenantId,
                        administorName,
                        new ContactInformation(
                            emailAddress,
                            postalAddress,
                            primaryTelephone,
                            secondaryTelephone)));

            tenant.WithdrawInvitation(invitation.InvitationId);

            this.userRepository.Add(admin);

            var adminRole = tenant.ProvisionRole("Administrator", "Default " + tenant.Name + " administrator.");

            adminRole.AssignUser(admin);

            this.roleRepository.Add(adminRole);

            DomainEventPublisher.Instance.Publish(new TenantAdministratorRegistered(tenant.TenantId, tenant.Name, administorName, emailAddress, admin.Username, strongPassword));
        }
        private void RegisterAdministratorFor(
            Tenant tenant,
            FullName administorName,
            EmailAddress emailAddress,
            PostalAddress postalAddress,
            Telephone primaryTelephone,
            Telephone secondaryTelephone)
        {
            RegistrationInvitation invitation = tenant.OfferRegistrationInvitation("init").OpenEnded();
            string strongPassword             = new PasswordService().GenerateStrongPassword();

            // Publishes domain event UserRegistered.
            User admin = tenant.RegisterUser(
                invitation.InvitationId,
                "admin",
                strongPassword,
                Enablement.IndefiniteEnablement(),
                new Person(
                    tenant.TenantId,
                    administorName,
                    new ContactInformation(
                        emailAddress,
                        postalAddress,
                        primaryTelephone,
                        secondaryTelephone)));

            tenant.WithdrawInvitation(invitation.InvitationId);

            // Since this is a new entity, add it to
            // the collection-oriented repository.
            // Subsequent changes to the entity
            // are implicitly persisted.
            this.userRepository.Add(admin);

            // Publishes domain event RoleProvisioned.
            Role adminRole = tenant.ProvisionRole(
                "Administrator",
                string.Format("Default {0} administrator.", tenant.Name));

            // Publishes domain event UserAssignedToRole,
            // but not GroupUserAdded because the group
            // reference held by the role is an "internal" group.
            adminRole.AssignUser(admin);

            // Since this is a new entity, add it to
            // the collection-oriented repository.
            // Subsequent changes to the entity
            // are implicitly persisted.
            this.roleRepository.Add(adminRole);

            DomainEventPublisher
            .Instance
            .Publish(new TenantAdministratorRegistered(
                         tenant.TenantId,
                         tenant.Name,
                         administorName,
                         emailAddress,
                         admin.Username,
                         strongPassword));
        }
        void RegisterAdministratorFor(Tenant tenant, FullName administorName, EmailAddress emailAddress, PostalAddress postalAddress, Telephone primaryTelephone, Telephone secondaryTelephone)
        {
            var invitation = tenant.OfferRegistrationInvitation("init").OpenEnded();

            var strongPassword = new PasswordService().GenerateStrongPassword();

            var admin =
                tenant.RegisterUser(
                        invitation.InvitationId,
                        "admin",
                        strongPassword,
                        Enablement.IndefiniteEnablement(),
                        new Person(
                                tenant.TenantId,
                                administorName,
                                new ContactInformation(
                                        emailAddress,
                                        postalAddress,
                                        primaryTelephone,
                                        secondaryTelephone)));

            tenant.WithdrawInvitation(invitation.InvitationId);

            this.userRepository.Add(admin);

            var adminRole = tenant.ProvisionRole("Administrator", "Default " + tenant.Name + " administrator.");

            adminRole.AssignUser(admin);

            this.roleRepository.Add(adminRole);

            DomainEventPublisher.Instance.Publish(new TenantAdministratorRegistered(tenant.TenantId, tenant.Name, administorName, emailAddress, admin.Username, strongPassword));
        }
		private void RegisterAdministratorFor(
			Tenant tenant,
			FullName administorName,
			EmailAddress emailAddress,
			PostalAddress postalAddress,
			Telephone primaryTelephone,
			Telephone secondaryTelephone)
		{
			RegistrationInvitation invitation = tenant.OfferRegistrationInvitation("init").OpenEnded();
			string strongPassword = new PasswordService().GenerateStrongPassword();

			// Publishes domain event UserRegistered.
			User admin = tenant.RegisterUser(
				invitation.InvitationId,
				"admin",
				strongPassword,
				Enablement.IndefiniteEnablement(),
				new Person(
					tenant.TenantId,
					administorName,
					new ContactInformation(
						emailAddress,
						postalAddress,
						primaryTelephone,
						secondaryTelephone)));

			tenant.WithdrawInvitation(invitation.InvitationId);

			// Since this is a new entity, add it to
			// the collection-oriented repository.
			// Subsequent changes to the entity
			// are implicitly persisted.
			this.userRepository.Add(admin);

			// Publishes domain event RoleProvisioned.
			Role adminRole = tenant.ProvisionRole(
				"Administrator",
				string.Format("Default {0} administrator.", tenant.Name));

			// Publishes domain event UserAssignedToRole,
			// but not GroupUserAdded because the group
			// reference held by the role is an "internal" group.
			adminRole.AssignUser(admin);

			// Since this is a new entity, add it to
			// the collection-oriented repository.
			// Subsequent changes to the entity
			// are implicitly persisted.
			this.roleRepository.Add(adminRole);

			DomainEventPublisher
				.Instance
				.Publish(new TenantAdministratorRegistered(
						tenant.TenantId,
						tenant.Name,
						administorName,
						emailAddress,
						admin.Username,
						strongPassword));
		}