예제 #1
0
파일: LolzController.cs 프로젝트: rafoch/MT
        public IActionResult Context([FromQuery] Guid tenantId)
        {
            _provider.Set(tenantId);
            var tenantObject = _dbContextFactory.Create();
            var first        = tenantObject.TenantObject.ToList();

            return(Ok(first));
        }
예제 #2
0
        /// <summary>
        /// Sets <see cref="Tenant{TKey}.Id"/> value in <see cref="ITenantProvider{TTenant,TKey}.Set"/> method
        /// </summary>
        /// <param name="httpContext"><see cref="HttpContext"/></param>
        /// <param name="provider"><see cref="ITenantProvider{TTenant,TKey}"/></param>
        /// <returns></returns>
        public async Task Invoke(HttpContext httpContext, ITenantProvider <TTenant, TKey> provider)
        {
            var requestHeader = httpContext.Request.Headers[Constans.Constans.TenantIdHeaderKey];

            if (requestHeader.Count != 0)
            {
                var key = (TKey)TypeDescriptor.GetConverter(typeof(TKey)).ConvertFromInvariantString(requestHeader[0]);
                provider.Set(key);
            }

            await _next(httpContext);
        }