add defensive logic to Alias.Path, improve new GetAlias method
This commit is contained in:
parent
edad4e7d35
commit
4cea22d813
|
@ -26,13 +26,14 @@ namespace Oqtane.Infrastructure
|
|||
{
|
||||
Alias alias = null;
|
||||
|
||||
// does not support mock Alias objects (GetTenant should be used to retrieve a TenantId)
|
||||
if (_siteState?.Alias != null && _siteState.Alias.AliasId != -1)
|
||||
{
|
||||
alias = _siteState.Alias;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there is http context
|
||||
// if there is HttpContext
|
||||
var httpcontext = _httpContextAccessor.HttpContext;
|
||||
if (httpcontext != null)
|
||||
{
|
||||
|
@ -78,20 +79,19 @@ namespace Oqtane.Infrastructure
|
|||
return null;
|
||||
}
|
||||
|
||||
// background processes can set the alias using the SiteState service
|
||||
public void SetAlias(Alias alias)
|
||||
{
|
||||
// background processes can set the alias using the SiteState service
|
||||
_siteState.Alias = alias;
|
||||
}
|
||||
|
||||
public void SetAlias(int tenantId, int siteId)
|
||||
{
|
||||
// background processes can set the alias using the SiteState service
|
||||
_siteState.Alias = new Alias { TenantId = tenantId, AliasId = -1, SiteId = siteId };
|
||||
_siteState.Alias = _aliasRepository.GetAliases().ToList().FirstOrDefault(item => item.TenantId == tenantId && item.SiteId == siteId);
|
||||
}
|
||||
|
||||
public void SetTenant(int tenantId)
|
||||
{
|
||||
// background processes can set the alias using the SiteState service
|
||||
_siteState.Alias = new Alias { TenantId = tenantId, AliasId = -1, SiteId = -1 };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Oqtane.Models
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Name.Contains("/"))
|
||||
if (Name != null && Name.Contains("/"))
|
||||
{
|
||||
return Name.Substring(Name.IndexOf("/") + 1);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace Oqtane.Models
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unique key used for identifying a site within a runtime process (ie. cache, etc...)
|
||||
/// Unique key used for identifying a site within a runtime process (ie. cache, file system, etc...)
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public string SiteKey
|
||||
|
|
Loading…
Reference in New Issue
Block a user