protected static Person PersonEntity(Tenant tenant) { return new Person(tenant.TenantId, new FullName("Colin", "Zhang"), new ContactInformation(new EmailAddress("*****@*****.**"), new PostalAddress("123 Pearl Street", "Boulder", "CO", "80301", "US"), new Telephone("303-555-1210"), new Telephone("303-555-1212"))); }
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; }
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)); }
public void Add(Tenant tenant) { if(this.Get(tenant.TenantId)!=null) { throw new InvalidOperationException("Tenant is not unique."); } _session.Save(tenant); }
public Tenant ProvisionTenant(string tenantName, string tenantDescription, FullName administorName, EmailAddress emailAddress, PostalAddress postalAddress, Telephone primaryTelephone, Telephone secondaryTelephone) { try { Tenant tenant = new Tenant(_tenantRepository.GetNextIdentity(), tenantName, tenantDescription, true); _tenantRepository.Add(tenant); RegisterAdministratorFor(tenant, administorName, emailAddress, postalAddress, primaryTelephone, secondaryTelephone); DomainEventPublisher.Instance.Publish(new TenantProvisioned(tenant.TenantId)); return tenant; } catch(Exception e) { throw new InvalidOperationException("Cannot provision tenant because: " + e.Message); } }
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)); }
protected Role CreateRole(Tenant tenant) { return tenant.ProvisionRole("Test role", "A test role.", true); }
protected Group CreateGroup2(Tenant tenant) { return tenant.ProvisionGroup("Test group 2", "A test group 2."); }
public void Remove(Tenant tenant) { _session.Delete(tenant); }