69 lines
2.6 KiB
C#
69 lines
2.6 KiB
C#
|
|
using System;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using Kurs.Platform.ListForms.DynamicApi;
|
|||
|
|
using Kurs.Platform.Localization;
|
|||
|
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
|
using Volo.Abp;
|
|||
|
|
using Volo.Abp.Application.Dtos;
|
|||
|
|
using Volo.Abp.Data;
|
|||
|
|
using Volo.Abp.DependencyInjection;
|
|||
|
|
using Volo.Abp.Domain.Entities;
|
|||
|
|
using Volo.Abp.EventBus.Distributed;
|
|||
|
|
using Volo.Abp.EventBus.Local;
|
|||
|
|
using Volo.Abp.Identity;
|
|||
|
|
using Volo.Abp.TenantManagement;
|
|||
|
|
|
|||
|
|
namespace Kurs.Platform.Tenants;
|
|||
|
|
|
|||
|
|
[Authorize(TenantManagementPermissions.Tenants.Default)]
|
|||
|
|
[Dependency(ReplaceServices = true)]
|
|||
|
|
public class PlatformTenantAppService : TenantAppService, IPlatformTenantAppService
|
|||
|
|
{
|
|||
|
|
private readonly ITenantRepository tenantRepository;
|
|||
|
|
private readonly IDistributedEventBus distributedEventBus;
|
|||
|
|
private readonly ILocalEventBus localEventBus;
|
|||
|
|
|
|||
|
|
public PlatformTenantAppService(
|
|||
|
|
ITenantRepository tenantRepository,
|
|||
|
|
ITenantManager tenantManager,
|
|||
|
|
IDataSeeder dataSeeder,
|
|||
|
|
IDistributedEventBus distributedEventBus,
|
|||
|
|
ILocalEventBus localEventBus) : base(tenantRepository, tenantManager, dataSeeder, distributedEventBus, localEventBus)
|
|||
|
|
{
|
|||
|
|
this.tenantRepository = tenantRepository;
|
|||
|
|
this.distributedEventBus = distributedEventBus;
|
|||
|
|
this.localEventBus = localEventBus;
|
|||
|
|
|
|||
|
|
LocalizationResource = typeof(PlatformResource);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[AllowAnonymous]
|
|||
|
|
public override Task<PagedResultDto<TenantDto>> GetListAsync(GetTenantsInput input) => base.GetListAsync(input);
|
|||
|
|
|
|||
|
|
[RemoteService(false)]
|
|||
|
|
public override Task<TenantDto> CreateAsync(TenantCreateDto input) => throw new NotImplementedException();
|
|||
|
|
|
|||
|
|
[RemoteService(false)]
|
|||
|
|
public override Task<TenantDto> UpdateAsync(Guid id, TenantUpdateDto input) => base.UpdateAsync(id, input);
|
|||
|
|
|
|||
|
|
//TODO: Update ve Delete ConnectionString: Validation vt varsa değiştireceği zaman uyarı verilmeli
|
|||
|
|
|
|||
|
|
[Authorize(TenantManagementPermissions.Tenants.Update)]
|
|||
|
|
public async Task PostSeedTenantDataAsync(CreateUpdateTenantInput input)
|
|||
|
|
{
|
|||
|
|
var tenant = await tenantRepository.FindAsync(input.Id.Value) ?? throw new EntityNotFoundException();
|
|||
|
|
await distributedEventBus.PublishAsync(
|
|||
|
|
new ApplyDatabaseMigrationsEto
|
|||
|
|
{
|
|||
|
|
TenantId = tenant.Id,
|
|||
|
|
DatabaseName = tenant.Name,
|
|||
|
|
Properties =
|
|||
|
|
{
|
|||
|
|
{ IdentityDataSeedContributor.AdminEmailPropertyName, input.AdminEmail },
|
|||
|
|
{ IdentityDataSeedContributor.AdminPasswordPropertyName, input.AdminPassword },
|
|||
|
|
{ IdentityDataSeedContributor.AdminUserNamePropertyName, input.AdminEmail }
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|