コード例 #1
0
    public TenantConfiguration Find(string name)
    {
        var cacheKey    = CreateCacheKey(name);
        var httpContext = HttpContextAccessor?.HttpContext;

        if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration)
        {
            return(tenantConfiguration);
        }

        tenantConfiguration = Cache.GetOrAdd(
            cacheKey,
            () => AsyncHelper.RunSync(async() => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name))),
            () => new DistributedCacheEntryOptions
        {
            AbsoluteExpirationRelativeToNow =
                TimeSpan.FromMinutes(5)     //TODO: Should be configurable.
        }
            );

        if (httpContext != null)
        {
            httpContext.Items[cacheKey] = tenantConfiguration;
        }

        return(tenantConfiguration);
    }
コード例 #2
0
    public async Task <TenantConfiguration> FindAsync(Guid id)
    {
        var cacheKey    = CreateCacheKey(id);
        var httpContext = HttpContextAccessor?.HttpContext;

        if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration)
        {
            return(tenantConfiguration);
        }

        tenantConfiguration = await Cache.GetOrAddAsync(
            cacheKey,
            async() => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id)),
            () => new DistributedCacheEntryOptions
        {
            AbsoluteExpirationRelativeToNow =
                TimeSpan.FromMinutes(5)     //TODO: Should be configurable.
        }
            );

        if (httpContext != null)
        {
            httpContext.Items[cacheKey] = tenantConfiguration;
        }

        return(tenantConfiguration);
    }
コード例 #3
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            ValidateModel();

            var input = ObjectMapper.Map <TenantInfoModel, TenantUpdateDto>(Tenant);
            await TenantAppService.UpdateAsync(Tenant.Id, input);

            return(NoContent());
        }
コード例 #4
0
        public virtual async Task <IActionResult> OnGetAsync(Guid id)
        {
            var editionLookup = await EditionAppService.GetEditionLookupAsync();

            Editions = editionLookup.Items
                       .Select(x => new SelectListItem(x.DisplayName, x.Id.ToString()))
                       .ToList();

            Tenant = ObjectMapper.Map <TenantDto, TenantInfoModel>(
                await TenantAppService.GetAsync(id)
                );

            return(Page());
        }