mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.3 KiB
37 lines
1.3 KiB
using System.Threading.Tasks;
|
|
using Volo.Abp.Data;
|
|
using Volo.Abp.DependencyInjection;
|
|
using Volo.Abp.Threading;
|
|
|
|
namespace Volo.Abp.TenantManagement
|
|
{
|
|
public class AbpTenantManagementTestDataBuilder : ITransientDependency
|
|
{
|
|
private readonly ITenantRepository _tenantRepository;
|
|
private readonly ITenantManager _tenantManager;
|
|
|
|
public AbpTenantManagementTestDataBuilder(
|
|
ITenantRepository tenantRepository,
|
|
ITenantManager tenantManager)
|
|
{
|
|
_tenantRepository = tenantRepository;
|
|
_tenantManager = tenantManager;
|
|
}
|
|
|
|
public void Build()
|
|
{
|
|
AsyncHelper.RunSync(AddTenantsAsync);
|
|
}
|
|
|
|
private async Task AddTenantsAsync()
|
|
{
|
|
var acme = await _tenantManager.CreateAsync("acme");
|
|
acme.ConnectionStrings.Add(new TenantConnectionString(acme.Id, ConnectionStrings.DefaultConnectionStringName, "DefaultConnString-Value"));
|
|
acme.ConnectionStrings.Add(new TenantConnectionString(acme.Id, "MyConnString", "MyConnString-Value"));
|
|
await _tenantRepository.InsertAsync(acme);
|
|
|
|
var volosoft = await _tenantManager.CreateAsync("volosoft");
|
|
await _tenantRepository.InsertAsync(volosoft);
|
|
}
|
|
}
|
|
} |