Localization fixes - table definition, SQL script naming, SQL script not marked as Embedded Resource, changed column name from IsCurrrent to IsDefault to reflect intent, set default language for site in _Host
This commit is contained in:
		| @ -1,4 +1,4 @@ | ||||
| using System; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using Microsoft.AspNetCore.Http; | ||||
| @ -9,24 +9,49 @@ namespace Oqtane.Repository | ||||
| { | ||||
|     public class TenantResolver : ITenantResolver | ||||
|     { | ||||
|         private readonly Alias _alias; | ||||
|         private readonly Tenant _tenant; | ||||
|         private readonly IHttpContextAccessor _accessor; | ||||
|         private readonly IAliasRepository _aliasRepository; | ||||
|         private readonly ITenantRepository _tenantRepository; | ||||
|         private readonly SiteState _siteState; | ||||
|  | ||||
|         private Alias _alias; | ||||
|         private Tenant _tenant; | ||||
|  | ||||
|         public TenantResolver(IHttpContextAccessor accessor, IAliasRepository aliasRepository, ITenantRepository tenantRepository, SiteState siteState) | ||||
|         { | ||||
|             int aliasId = -1; | ||||
|             _accessor = accessor; | ||||
|             _aliasRepository = aliasRepository; | ||||
|             _tenantRepository = tenantRepository; | ||||
|             _siteState = siteState; | ||||
|         } | ||||
|  | ||||
|             if (siteState != null && siteState.Alias != null) | ||||
|         public Alias GetAlias() | ||||
|         { | ||||
|             if (_alias == null) ResolveTenant(); | ||||
|             return _alias; | ||||
|         } | ||||
|  | ||||
|         public Tenant GetTenant() | ||||
|         { | ||||
|             if (_tenant == null) ResolveTenant(); | ||||
|             return _tenant; | ||||
|         } | ||||
|  | ||||
|         private void ResolveTenant() | ||||
|         { | ||||
|             if (_siteState != null && _siteState.Alias != null) | ||||
|             { | ||||
|                 // background processes can pass in an alias using the SiteState service | ||||
|                 _alias = siteState.Alias; | ||||
|                 _alias = _siteState.Alias; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 int aliasId = -1; | ||||
|  | ||||
|                 // get aliasid identifier based on request | ||||
|                 if (accessor.HttpContext != null) | ||||
|                 if (_accessor.HttpContext != null) | ||||
|                 { | ||||
|                     string[] segments = accessor.HttpContext.Request.Path.Value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); | ||||
|                     string[] segments = _accessor.HttpContext.Request.Path.Value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); | ||||
|                     if (segments.Length > 1 && (segments[1] == "api" || segments[1] == "pages") && segments[0] != "~") | ||||
|                     { | ||||
|                         aliasId = int.Parse(segments[0]); | ||||
| @ -34,7 +59,7 @@ namespace Oqtane.Repository | ||||
|                 } | ||||
|  | ||||
|                 // get the alias | ||||
|                 IEnumerable<Alias> aliases = aliasRepository.GetAliases().ToList(); // cached | ||||
|                 IEnumerable<Alias> aliases = _aliasRepository.GetAliases().ToList(); // cached | ||||
|                 if (aliasId != -1) | ||||
|                 { | ||||
|                     _alias = aliases.FirstOrDefault(item => item.AliasId == aliasId); | ||||
| @ -44,19 +69,10 @@ namespace Oqtane.Repository | ||||
|             if (_alias != null) | ||||
|             { | ||||
|                 // get the tenant | ||||
|                 IEnumerable<Tenant> tenants = tenantRepository.GetTenants(); // cached | ||||
|                 IEnumerable<Tenant> tenants = _tenantRepository.GetTenants(); // cached | ||||
|                 _tenant = tenants.FirstOrDefault(item => item.TenantId == _alias.TenantId); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public Alias GetAlias() | ||||
|         { | ||||
|             return _alias; | ||||
|         } | ||||
|  | ||||
|         public Tenant GetTenant() | ||||
|         { | ||||
|             return _tenant; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker