Merge pull request #209 from hishamco/root-site

Unable to deleted the root site
This commit is contained in:
Shaun Walker
2020-02-22 10:03:23 -05:00
committed by GitHub
5 changed files with 41 additions and 11 deletions

View File

@ -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.");
}
}
}
}

View File

@ -142,10 +142,13 @@ 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)