Ejemplo n.º 1
0
        protected virtual async Task <TenantConfigurationCacheItem> GetCacheItemByIdAsync(Guid id)
        {
            var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(id.ToString());

            Logger.LogDebug($"TenantStore.GetCacheItemByIdAsync: {cacheKey}");

            var cacheItem = await _cache.GetAsync(cacheKey);

            if (cacheItem != null)
            {
                Logger.LogDebug($"Found in the cache: {cacheKey}");
                return(cacheItem);
            }
            Logger.LogDebug($"Not found in the cache, getting from the remote service: {cacheKey}");

            var tenantDto = await _tenantAppService.GetAsync(id);

            var tenantConnectionStringsDto = await _tenantAppService.GetConnectionStringAsync(id);

            var connectionStrings = new ConnectionStrings();

            foreach (var tenantConnectionString in tenantConnectionStringsDto.Items)
            {
                connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
            }
            cacheItem = new TenantConfigurationCacheItem(tenantDto.Id, tenantDto.Name, connectionStrings);

            Logger.LogDebug($"Setting the cache item: {cacheKey}");
            await _cache.SetAsync(cacheKey, cacheItem);

            Logger.LogDebug($"Finished setting the cache item: {cacheKey}");

            return(cacheItem);
        }
Ejemplo n.º 2
0
        public async Task GetAsync()
        {
            var tenantInDb = UsingDbContext(dbContext => dbContext.Tenants.First());
            var tenant     = await _tenantAppService.GetAsync(tenantInDb.Id).ConfigureAwait(false);

            tenant.Name.ShouldBe(tenantInDb.Name);
        }
        public virtual async Task HandleEventAsync(EntityCreatedEto <TenantEto> eventData)
        {
            var tenantDto = await _tenantAppService.GetAsync(eventData.Entity.Id);

            var tenantConnectionStringsDto = await _tenantAppService.GetConnectionStringAsync(eventData.Entity.Id);

            var connectionStrings = new ConnectionStrings();

            foreach (var tenantConnectionString in tenantConnectionStringsDto.Items)
            {
                connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
            }
            var cacheItem = new TenantConfigurationCacheItem(tenantDto.Id, tenantDto.Name, connectionStrings);

            var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
            await _cache.SetAsync(cacheKey, cacheItem);
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> EditModal(int tenantId)
        {
            var tenantDto = await _tenantAppService.GetAsync(new EntityDto(tenantId));

            return(PartialView("_EditModal", tenantDto));
        }
Ejemplo n.º 5
0
 public Task <TenantDto> GetAsync(Guid id)
 {
     return(_service.GetAsync(id));
 }
Ejemplo n.º 6
0
 public async Task <TenantDto> GetAsync(Guid id)
 {
     return(await _tenantAppService.GetAsync(id));
 }
Ejemplo n.º 7
0
 public Task <TenantDto> GetAsync(string id)
 {
     return(_tenantAppService.GetAsync(id.ToGuid()));
 }
Ejemplo n.º 8
0
        public async Task GetTenantById_Test()
        {
            var result = await _tenantAppService.GetAsync(new EntityDto <int>(1));

            result.TenancyName.ShouldBe("Default");
        }
 public Task <TenantDto> GetTenantAsync(EntityDto <int> input)
 {
     return(_tenantAppService.GetAsync(input));
 }