Server naming fixes and cleanup

Server is now completely cleaned up and without warnings
This commit is contained in:
Pavel Vesely
2020-03-15 09:38:37 +01:00
parent ab3f0853a7
commit 5b3feaf26f
92 changed files with 1223 additions and 1273 deletions

View File

@ -1,13 +1,11 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Oqtane.Repository;
using Oqtane.Models;
using Oqtane.Shared;
using System.Linq;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Oqtane.Infrastructure;
using Oqtane.Infrastructure.Interfaces;
using Oqtane.Repository;
namespace Oqtane.Controllers
{
@ -16,15 +14,13 @@ namespace Oqtane.Controllers
{
private readonly ISiteRepository _sites;
private readonly ITenantResolver _tenants;
private readonly IWebHostEnvironment _environment;
private readonly ISyncManager _syncManager;
private readonly ILogManager _logger;
public SiteController(ISiteRepository sites, ITenantResolver tenants, IWebHostEnvironment environment, ISyncManager syncManager, ILogManager logger)
public SiteController(ISiteRepository sites, ITenantResolver tenants, ISyncManager syncManager, ILogManager logger)
{
_sites = sites;
_tenants = tenants;
_environment = environment;
_syncManager = syncManager;
_logger = logger;
}
@ -46,7 +42,7 @@ namespace Oqtane.Controllers
// POST api/<controller>
[HttpPost]
public Site Post([FromBody] Site Site)
public Site Post([FromBody] Site site)
{
if (ModelState.IsValid)
{
@ -56,7 +52,7 @@ namespace Oqtane.Controllers
// provision initial site during installation
authorized = true;
Tenant tenant = _tenants.GetTenant();
Site.TenantId = tenant.TenantId;
site.TenantId = tenant.TenantId;
}
else
{
@ -64,25 +60,25 @@ namespace Oqtane.Controllers
}
if (authorized)
{
Site = _sites.AddSite(Site);
_logger.Log(Site.SiteId, LogLevel.Information, this, LogFunction.Create, "Site Added {Site}", Site);
site = _sites.AddSite(site);
_logger.Log(site.SiteId, LogLevel.Information, this, LogFunction.Create, "Site Added {Site}", site);
}
}
return Site;
return site;
}
// PUT api/<controller>/5
[HttpPut("{id}")]
[Authorize(Roles = Constants.HostRole)]
public Site Put(int id, [FromBody] Site Site)
public Site Put(int id, [FromBody] Site site)
{
if (ModelState.IsValid)
{
Site = _sites.UpdateSite(Site);
_syncManager.AddSyncEvent(EntityNames.Site, Site.SiteId);
_logger.Log(Site.SiteId, LogLevel.Information, this, LogFunction.Update, "Site Updated {Site}", Site);
site = _sites.UpdateSite(site);
_syncManager.AddSyncEvent(EntityNames.Site, site.SiteId);
_logger.Log(site.SiteId, LogLevel.Information, this, LogFunction.Update, "Site Updated {Site}", site);
}
return Site;
return site;
}
// DELETE api/<controller>/5