|
|
|
@ -27,14 +27,13 @@ namespace Volo.Abp.TenantManagement
|
|
|
|
|
public virtual async Task<TenantDto> GetAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
return ObjectMapper.Map<Tenant, TenantDto>(
|
|
|
|
|
await TenantRepository.GetAsync(id)
|
|
|
|
|
);
|
|
|
|
|
await TenantRepository.GetAsync(id).ConfigureAwait(false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task<PagedResultDto<TenantDto>> GetListAsync(GetTenantsInput input)
|
|
|
|
|
{
|
|
|
|
|
var count = await TenantRepository.GetCountAsync(input.Filter);
|
|
|
|
|
var list = await TenantRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter);
|
|
|
|
|
var count = await TenantRepository.GetCountAsync(input.Filter).ConfigureAwait(false);
|
|
|
|
|
var list = await TenantRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
return new PagedResultDto<TenantDto>(
|
|
|
|
|
count,
|
|
|
|
@ -45,15 +44,15 @@ namespace Volo.Abp.TenantManagement
|
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.Create)]
|
|
|
|
|
public virtual async Task<TenantDto> CreateAsync(TenantCreateDto input)
|
|
|
|
|
{
|
|
|
|
|
var tenant = await TenantManager.CreateAsync(input.Name);
|
|
|
|
|
await TenantRepository.InsertAsync(tenant);
|
|
|
|
|
var tenant = await TenantManager.CreateAsync(input.Name).ConfigureAwait(false);
|
|
|
|
|
await TenantRepository.InsertAsync(tenant).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
using (CurrentTenant.Change(tenant.Id, tenant.Name))
|
|
|
|
|
{
|
|
|
|
|
//TODO: Handle database creation?
|
|
|
|
|
|
|
|
|
|
//TODO: Set admin email & password..?
|
|
|
|
|
await DataSeeder.SeedAsync(tenant.Id);
|
|
|
|
|
await DataSeeder.SeedAsync(tenant.Id).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ObjectMapper.Map<Tenant, TenantDto>(tenant);
|
|
|
|
@ -62,45 +61,45 @@ namespace Volo.Abp.TenantManagement
|
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.Update)]
|
|
|
|
|
public virtual async Task<TenantDto> UpdateAsync(Guid id, TenantUpdateDto input)
|
|
|
|
|
{
|
|
|
|
|
var tenant = await TenantRepository.GetAsync(id);
|
|
|
|
|
await TenantManager.ChangeNameAsync(tenant, input.Name);
|
|
|
|
|
await TenantRepository.UpdateAsync(tenant);
|
|
|
|
|
var tenant = await TenantRepository.GetAsync(id).ConfigureAwait(false);
|
|
|
|
|
await TenantManager.ChangeNameAsync(tenant, input.Name).ConfigureAwait(false);
|
|
|
|
|
await TenantRepository.UpdateAsync(tenant).ConfigureAwait(false);
|
|
|
|
|
return ObjectMapper.Map<Tenant, TenantDto>(tenant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.Delete)]
|
|
|
|
|
public virtual async Task DeleteAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var tenant = await TenantRepository.FindAsync(id);
|
|
|
|
|
var tenant = await TenantRepository.FindAsync(id).ConfigureAwait(false);
|
|
|
|
|
if (tenant == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantRepository.DeleteAsync(tenant);
|
|
|
|
|
await TenantRepository.DeleteAsync(tenant).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)]
|
|
|
|
|
public virtual async Task<string> GetDefaultConnectionStringAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var tenant = await TenantRepository.GetAsync(id);
|
|
|
|
|
var tenant = await TenantRepository.GetAsync(id).ConfigureAwait(false);
|
|
|
|
|
return tenant?.FindDefaultConnectionString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)]
|
|
|
|
|
public virtual async Task UpdateDefaultConnectionStringAsync(Guid id, string defaultConnectionString)
|
|
|
|
|
{
|
|
|
|
|
var tenant = await TenantRepository.GetAsync(id);
|
|
|
|
|
var tenant = await TenantRepository.GetAsync(id).ConfigureAwait(false);
|
|
|
|
|
tenant.SetDefaultConnectionString(defaultConnectionString);
|
|
|
|
|
await TenantRepository.UpdateAsync(tenant);
|
|
|
|
|
await TenantRepository.UpdateAsync(tenant).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Authorize(TenantManagementPermissions.Tenants.ManageConnectionStrings)]
|
|
|
|
|
public virtual async Task DeleteDefaultConnectionStringAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var tenant = await TenantRepository.GetAsync(id);
|
|
|
|
|
var tenant = await TenantRepository.GetAsync(id).ConfigureAwait(false);
|
|
|
|
|
tenant.RemoveDefaultConnectionString();
|
|
|
|
|
await TenantRepository.UpdateAsync(tenant);
|
|
|
|
|
await TenantRepository.UpdateAsync(tenant).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|