Merge pull request #209 from hishamco/root-site
Unable to deleted the root site
This commit is contained in:
commit
07b29bff1f
|
@ -20,7 +20,7 @@ else
|
|||
</Header>
|
||||
<Row>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.AliasId.ToString())" /></td>
|
||||
<td><ActionDialog Header="Delete Site" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Site?")" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteSite(context))" /></td>
|
||||
<td><ActionDialog Header="Delete Site" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Site?")" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteSite(context))" Disabled="sites.Count == 1" /></td>
|
||||
<td><a href="@(scheme + context.Name)">@context.Name</a></td>
|
||||
</Row>
|
||||
</Pager>
|
||||
|
|
|
@ -28,7 +28,14 @@
|
|||
}
|
||||
@if (authorized)
|
||||
{
|
||||
<button class="@Class" @onclick="DisplayModal">@Text</button>
|
||||
if (Disabled)
|
||||
{
|
||||
<button class="@Class" disabled @onclick="DisplayModal">@Text</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="@Class" @onclick="DisplayModal">@Text</button>
|
||||
}
|
||||
}
|
||||
|
||||
@code {
|
||||
|
@ -50,6 +57,9 @@
|
|||
[Parameter]
|
||||
public string Class { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public string EditMode { get; set; } // optional - specifies if a user must be in edit mode to see the action - default is true
|
||||
|
||||
|
|
|
@ -4,7 +4,14 @@
|
|||
|
||||
@if (authorized)
|
||||
{
|
||||
<NavLink class="@classname" href="@url" style="@style">@text</NavLink>
|
||||
if (Disabled)
|
||||
{
|
||||
<NavLink class="@classname" href="@url" style="@style" disabled>@text</NavLink>
|
||||
}
|
||||
else
|
||||
{
|
||||
<NavLink class="@classname" href="@url" style="@style">@text</NavLink>
|
||||
}
|
||||
}
|
||||
|
||||
@code {
|
||||
|
@ -26,6 +33,9 @@
|
|||
[Parameter]
|
||||
public string Style { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; } // optional
|
||||
|
||||
[Parameter]
|
||||
public string EditMode { get; set; } // optional - specifies if a user must be in edit mode to see the action - default is true
|
||||
|
||||
|
|
|
@ -87,8 +87,15 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Sites.DeleteSite(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Site Deleted {SiteId}", id);
|
||||
if (Sites.GetSites().Count() > 1)
|
||||
{
|
||||
Sites.DeleteSite(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Site Deleted {SiteId}", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Warning, this, LogFunction.Delete, "Unable to delete the root site.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,9 +143,12 @@ namespace Oqtane.Repository
|
|||
|
||||
public void DeleteSite(int siteId)
|
||||
{
|
||||
Site site = db.Site.Find(siteId);
|
||||
db.Site.Remove(site);
|
||||
db.SaveChanges();
|
||||
if (db.Site.Count() > 1)
|
||||
{
|
||||
var site = db.Site.Find(siteId);
|
||||
db.Site.Remove(site);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSite(Site site)
|
||||
|
|
Loading…
Reference in New Issue
Block a user