Skip to content

The open source simple and complete warehouse management system is derived from our many years of experience in implementing erp projects. We stripped the original commercial system wms function and opened it up for free, hoping to help the majority of small and medium-sized enterprises. At present, the system supports cross-platform。

1.2 KB
Raw Blame
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ModernWMS.Core.MultiTenancy
{
    /// <summary>
    /// TenantProvider
    /// </summary>
    public class TenantProvider:ITenantProvider
    {
        /// <summary>
        /// Tenant
        /// </summary>
        private readonly Tenant tenant;
        /// <summary>
        /// TenantProvider
        /// </summary>
        /// <param name="accessor">注入IHttpContextAccessor</param>
        public TenantProvider(IHttpContextAccessor accessor)
        {
            if (accessor.HttpContext != null)
            {
                var headers = accessor.HttpContext.Request.Headers;
                if (headers != null && headers.Count > 0
                    && headers.ContainsKey("TenantName"))
                {
                    var name = headers["TenantName"].FirstOrDefault();
                }
            }
            //Default Value
            tenant = new Tenant();
        }

        /// <summary>
        /// Get Current User's TenantID
        /// </summary>
        /// <returns></returns>
        public byte GetCurrentTenantID()
        {
            return tenant.tenant_id;
        }
    }
}