コード例 #1
0
 private static User CreateUser2(Tenant tenant)
 {
     RegistrationInvitation registrationInvitation = tenant.OfferRegistrationInvitation("User2Registration");
     User user2 = tenant.RegisterUser(registrationInvitation.InvitationId,
         "colinZhang", "secretPassword!", Enablement.IndefiniteEnablement(), PersonEntity(tenant));
     return user2;
 }
コード例 #2
0
 protected User CreateUser(Tenant tenant)
 {
     DateTime now = DateTime.Now;
     RegistrationInvitation registrationInvitation =
         tenant.OfferRegistrationInvitation("Today-and-Tomorrow").WillStartOn(now).LastingUntil(now.AddDays(1));
     return tenant.RegisterUser(registrationInvitation.InvitationId,
         "colin", "secretPassword!", Enablement.IndefiniteEnablement(), PersonEntity(tenant));
 }
コード例 #3
0
        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();

            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);
            _userRepository.Add(admin);

            Role adminRole = tenant.ProvisionRole("Administrator", "Default" + tenant.Name + " administrator.");
            adminRole.AssignUser(admin);
            _roleRepository.Add(adminRole);

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