Refactor TenantNames.Master
This commit is contained in:
parent
3e71bdfef3
commit
c683de2cda
@ -9,7 +9,7 @@
|
||||
<Label For="name" HelpText="The name of the tenant">Name: </Label>
|
||||
</td>
|
||||
<td>
|
||||
@if (name == Constants.MasterTenant)
|
||||
@if (name == TenantNames.Master)
|
||||
{
|
||||
<input id="name" class="form-control" @bind="@name" readonly />
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ else
|
||||
</Header>
|
||||
<Row>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.TenantId.ToString())" /></td>
|
||||
<td><ActionDialog Header="Delete Tenant" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Tenant?")" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteTenant(context))" Disabled="@(context.Name == Constants.MasterTenant)" /></td>
|
||||
<td><ActionDialog Header="Delete Tenant" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Tenant?")" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteTenant(context))" Disabled="@(context.Name == TenantNames.Master)" /></td>
|
||||
<td>@context.Name</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
|
@ -131,7 +131,7 @@
|
||||
private string _databaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
private string _username = string.Empty;
|
||||
private string _password = string.Empty;
|
||||
private string _hostUsername = Constants.HostUser;
|
||||
private string _hostUsername = UserNames.Host;
|
||||
private string _hostPassword = string.Empty;
|
||||
private string _confirmPassword = string.Empty;
|
||||
private string _hostEmail = string.Empty;
|
||||
@ -188,8 +188,8 @@
|
||||
Aliases = uri.Authority,
|
||||
HostEmail = _hostEmail,
|
||||
HostPassword = _hostPassword,
|
||||
HostName = Constants.HostUser,
|
||||
TenantName = Constants.MasterTenant,
|
||||
HostName = UserNames.Host,
|
||||
TenantName = TenantNames.Master,
|
||||
IsNewTenant = true,
|
||||
SiteName = Constants.DefaultSite
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ namespace Oqtane.Infrastructure
|
||||
if (install == null)
|
||||
{
|
||||
// startup or silent installation
|
||||
install = new InstallConfig { ConnectionString = _config.GetConnectionString(SettingKeys.ConnectionStringKey), TenantName = Constants.MasterTenant, IsNewTenant = false };
|
||||
install = new InstallConfig { ConnectionString = _config.GetConnectionString(SettingKeys.ConnectionStringKey), TenantName = TenantNames.Master, IsNewTenant = false };
|
||||
|
||||
if (!IsInstalled())
|
||||
{
|
||||
@ -192,7 +192,7 @@ namespace Oqtane.Infrastructure
|
||||
{
|
||||
var result = new Installation { Success = false, Message = string.Empty };
|
||||
|
||||
if (install.TenantName == Constants.MasterTenant)
|
||||
if (install.TenantName == TenantNames.Master)
|
||||
{
|
||||
MigrateScriptNamingConvention("Master", install.ConnectionString);
|
||||
|
||||
@ -245,7 +245,7 @@ namespace Oqtane.Infrastructure
|
||||
db.SaveChanges();
|
||||
_cache.Remove("tenants");
|
||||
|
||||
if (install.TenantName == Constants.MasterTenant)
|
||||
if (install.TenantName == TenantNames.Master)
|
||||
{
|
||||
var job = new Job { Name = "Notification Job", JobType = "Oqtane.Infrastructure.NotificationJob, Oqtane.Server", Frequency = "m", Interval = 1, StartDate = null, EndDate = null, IsEnabled = false, IsStarted = false, IsExecuting = false, NextExecution = null, RetentionHistory = 10, CreatedBy = "", CreatedOn = DateTime.UtcNow, ModifiedBy = "", ModifiedOn = DateTime.UtcNow };
|
||||
db.Job.Add(job);
|
||||
@ -350,7 +350,7 @@ namespace Oqtane.Infrastructure
|
||||
foreach (var tenant in db.Tenant.ToList())
|
||||
{
|
||||
int index = Array.FindIndex(versions, item => item == moduledefinition.Version);
|
||||
if (tenant.Name == install.TenantName && install.TenantName != Constants.MasterTenant)
|
||||
if (tenant.Name == install.TenantName && install.TenantName != TenantNames.Master)
|
||||
{
|
||||
index = -1;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
var oldTenant =_db.Tenant.AsNoTracking().FirstOrDefault(t=> t.TenantId == tenant.TenantId);
|
||||
|
||||
if (oldTenant != null && (oldTenant.Name.Equals(Constants.MasterTenant, StringComparison.OrdinalIgnoreCase) && !oldTenant.Name.Equals(tenant.Name)))
|
||||
if (oldTenant != null && (oldTenant.Name.Equals(TenantNames.Master, StringComparison.OrdinalIgnoreCase) && !oldTenant.Name.Equals(tenant.Name)))
|
||||
{
|
||||
throw new InvalidOperationException("Unable to rename the master tenant.");
|
||||
}
|
||||
@ -59,7 +59,7 @@ namespace Oqtane.Repository
|
||||
public void DeleteTenant(int tenantId)
|
||||
{
|
||||
var tenant = GetTenant(tenantId);
|
||||
if (tenant != null && !tenant.Name.Equals(Constants.MasterTenant, StringComparison.OrdinalIgnoreCase))
|
||||
if (tenant != null && !tenant.Name.Equals(TenantNames.Master, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_db.Tenant.Remove(tenant);
|
||||
_db.SaveChanges();
|
||||
|
@ -40,7 +40,8 @@ namespace Oqtane.Shared {
|
||||
[Obsolete("Use UserNames.Host instead.")]
|
||||
public const string HostUser = UserNames.Host;
|
||||
|
||||
public const string MasterTenant = "Master";
|
||||
[Obsolete("Use TenantNames.Master instead")]
|
||||
public const string MasterTenant = TenantNames.Master;
|
||||
public const string DefaultSite = "Default Site";
|
||||
|
||||
const string RoleObsoleteMessage = "Use the corresponding memeber from Oqtane.Shared.RoleNames";
|
||||
|
9
Oqtane.Shared/Shared/TenantNames.cs
Normal file
9
Oqtane.Shared/Shared/TenantNames.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Oqtane.Shared {
|
||||
public class TenantNames {
|
||||
public const string Master = "Master";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user