Fix naming conventions for private fields
This commit is contained in:
parent
e74f0d7644
commit
a46235ea1e
|
@ -13,22 +13,22 @@ namespace Oqtane.Providers
|
|||
{
|
||||
public class IdentityAuthenticationStateProvider : AuthenticationStateProvider
|
||||
{
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly IServiceProvider provider;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public IdentityAuthenticationStateProvider(NavigationManager NavigationManager, SiteState sitestate, IServiceProvider provider)
|
||||
{
|
||||
this.NavigationManager = NavigationManager;
|
||||
this.sitestate = sitestate;
|
||||
this.provider = provider;
|
||||
this._navigationManager = NavigationManager;
|
||||
this._siteState = sitestate;
|
||||
this._serviceProvider = provider;
|
||||
}
|
||||
|
||||
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||
{
|
||||
// get HttpClient lazily from IServiceProvider as you cannot use standard dependency injection due to the AuthenticationStateProvider being initialized prior to NavigationManager ( https://github.com/aspnet/AspNetCore/issues/11867 )
|
||||
var http = provider.GetRequiredService<HttpClient>();
|
||||
string apiurl = ServiceBase.CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "User") + "/authenticate";
|
||||
var http = _serviceProvider.GetRequiredService<HttpClient>();
|
||||
string apiurl = ServiceBase.CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "User") + "/authenticate";
|
||||
User user = await http.GetJsonAsync<User>(apiurl);
|
||||
|
||||
ClaimsIdentity identity = new ClaimsIdentity();
|
||||
|
|
|
@ -12,31 +12,31 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class AliasService : ServiceBase, IAliasService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public AliasService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Alias"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Alias"); }
|
||||
}
|
||||
|
||||
public async Task<List<Alias>> GetAliasesAsync()
|
||||
{
|
||||
List<Alias> aliases = await http.GetJsonAsync<List<Alias>>(apiurl);
|
||||
List<Alias> aliases = await _http.GetJsonAsync<List<Alias>>(apiurl);
|
||||
return aliases.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Alias> GetAliasAsync(int AliasId)
|
||||
{
|
||||
return await http.GetJsonAsync<Alias>(apiurl + "/" + AliasId.ToString());
|
||||
return await _http.GetJsonAsync<Alias>(apiurl + "/" + AliasId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Alias> GetAliasAsync(string Url)
|
||||
|
@ -51,21 +51,21 @@ namespace Oqtane.Services
|
|||
{
|
||||
name = name.Substring(0, name.Length - 1);
|
||||
}
|
||||
return await http.GetJsonAsync<Alias>(apiurl + "/name/" + WebUtility.UrlEncode(name));
|
||||
return await _http.GetJsonAsync<Alias>(apiurl + "/name/" + WebUtility.UrlEncode(name));
|
||||
}
|
||||
|
||||
public async Task<Alias> AddAliasAsync(Alias alias)
|
||||
{
|
||||
return await http.PostJsonAsync<Alias>(apiurl, alias);
|
||||
return await _http.PostJsonAsync<Alias>(apiurl, alias);
|
||||
}
|
||||
|
||||
public async Task<Alias> UpdateAliasAsync(Alias alias)
|
||||
{
|
||||
return await http.PutJsonAsync<Alias>(apiurl + "/" + alias.AliasId.ToString(), alias);
|
||||
return await _http.PutJsonAsync<Alias>(apiurl + "/" + alias.AliasId.ToString(), alias);
|
||||
}
|
||||
public async Task DeleteAliasAsync(int AliasId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + AliasId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + AliasId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,22 +12,22 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class FileService : ServiceBase, IFileService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly IJSRuntime jsRuntime;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
private readonly IJSRuntime _jsRuntime;
|
||||
|
||||
public FileService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager, IJSRuntime jsRuntime)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this.jsRuntime = jsRuntime;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
this._jsRuntime = jsRuntime;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "File"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "File"); }
|
||||
}
|
||||
|
||||
public async Task<List<File>> GetFilesAsync(int FolderId)
|
||||
|
@ -37,32 +37,32 @@ namespace Oqtane.Services
|
|||
|
||||
public async Task<List<File>> GetFilesAsync(string Folder)
|
||||
{
|
||||
return await http.GetJsonAsync<List<File>>(apiurl + "?folder=" + Folder);
|
||||
return await _http.GetJsonAsync<List<File>>(apiurl + "?folder=" + Folder);
|
||||
}
|
||||
|
||||
public async Task<File> GetFileAsync(int FileId)
|
||||
{
|
||||
return await http.GetJsonAsync<File>(apiurl + "/" + FileId.ToString());
|
||||
return await _http.GetJsonAsync<File>(apiurl + "/" + FileId.ToString());
|
||||
}
|
||||
|
||||
public async Task<File> AddFileAsync(File File)
|
||||
{
|
||||
return await http.PostJsonAsync<File>(apiurl, File);
|
||||
return await _http.PostJsonAsync<File>(apiurl, File);
|
||||
}
|
||||
|
||||
public async Task<File> UpdateFileAsync(File File)
|
||||
{
|
||||
return await http.PutJsonAsync<File>(apiurl + "/" + File.FileId.ToString(), File);
|
||||
return await _http.PutJsonAsync<File>(apiurl + "/" + File.FileId.ToString(), File);
|
||||
}
|
||||
|
||||
public async Task DeleteFileAsync(int FileId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + FileId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + FileId.ToString());
|
||||
}
|
||||
|
||||
public async Task<File> UploadFileAsync(string Url, int FolderId)
|
||||
{
|
||||
return await http.GetJsonAsync<File>(apiurl + "/upload?url=" + WebUtility.UrlEncode(Url) + "&folderid=" + FolderId.ToString());
|
||||
return await _http.GetJsonAsync<File>(apiurl + "/upload?url=" + WebUtility.UrlEncode(Url) + "&folderid=" + FolderId.ToString());
|
||||
}
|
||||
|
||||
public async Task<string> UploadFilesAsync(int FolderId, string[] Files, string Id)
|
||||
|
@ -74,7 +74,7 @@ namespace Oqtane.Services
|
|||
{
|
||||
string result = "";
|
||||
|
||||
var interop = new Interop(jsRuntime);
|
||||
var interop = new Interop(_jsRuntime);
|
||||
await interop.UploadFiles(apiurl + "/upload", Folder, Id);
|
||||
|
||||
// uploading files is asynchronous so we need to wait for the upload to complete
|
||||
|
@ -110,7 +110,7 @@ namespace Oqtane.Services
|
|||
|
||||
public async Task<byte[]> DownloadFileAsync(int FileId)
|
||||
{
|
||||
return await http.GetByteArrayAsync(apiurl + "/download/" + FileId.ToString());
|
||||
return await _http.GetByteArrayAsync(apiurl + "/download/" + FileId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,52 +11,52 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class FolderService : ServiceBase, IFolderService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public FolderService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Folder"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Folder"); }
|
||||
}
|
||||
|
||||
public async Task<List<Folder>> GetFoldersAsync(int SiteId)
|
||||
{
|
||||
List<Folder> folders = await http.GetJsonAsync<List<Folder>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<Folder> folders = await _http.GetJsonAsync<List<Folder>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
folders = GetFoldersHierarchy(folders);
|
||||
return folders;
|
||||
}
|
||||
|
||||
public async Task<Folder> GetFolderAsync(int FolderId)
|
||||
{
|
||||
return await http.GetJsonAsync<Folder>(apiurl + "/" + FolderId.ToString());
|
||||
return await _http.GetJsonAsync<Folder>(apiurl + "/" + FolderId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Folder> AddFolderAsync(Folder Folder)
|
||||
{
|
||||
return await http.PostJsonAsync<Folder>(apiurl, Folder);
|
||||
return await _http.PostJsonAsync<Folder>(apiurl, Folder);
|
||||
}
|
||||
|
||||
public async Task<Folder> UpdateFolderAsync(Folder Folder)
|
||||
{
|
||||
return await http.PutJsonAsync<Folder>(apiurl + "/" + Folder.FolderId.ToString(), Folder);
|
||||
return await _http.PutJsonAsync<Folder>(apiurl + "/" + Folder.FolderId.ToString(), Folder);
|
||||
}
|
||||
|
||||
public async Task UpdateFolderOrderAsync(int SiteId, int FolderId, int? ParentId)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&folderid=" + FolderId.ToString() + "&parentid=" + ((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||
await _http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&folderid=" + FolderId.ToString() + "&parentid=" + ((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||
}
|
||||
|
||||
public async Task DeleteFolderAsync(int FolderId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + FolderId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + FolderId.ToString());
|
||||
}
|
||||
|
||||
private static List<Folder> GetFoldersHierarchy(List<Folder> Folders)
|
||||
|
|
|
@ -10,35 +10,35 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class InstallationService : ServiceBase, IInstallationService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public InstallationService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Installation"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Installation"); }
|
||||
}
|
||||
|
||||
public async Task<GenericResponse> IsInstalled()
|
||||
{
|
||||
return await http.GetJsonAsync<GenericResponse>(apiurl + "/installed");
|
||||
return await _http.GetJsonAsync<GenericResponse>(apiurl + "/installed");
|
||||
}
|
||||
|
||||
public async Task<GenericResponse> Install(string connectionstring)
|
||||
{
|
||||
return await http.PostJsonAsync<GenericResponse>(apiurl, connectionstring);
|
||||
return await _http.PostJsonAsync<GenericResponse>(apiurl, connectionstring);
|
||||
}
|
||||
|
||||
public async Task<GenericResponse> Upgrade()
|
||||
{
|
||||
return await http.GetJsonAsync<GenericResponse>(apiurl + "/upgrade");
|
||||
return await _http.GetJsonAsync<GenericResponse>(apiurl + "/upgrade");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,19 +11,19 @@ namespace Oqtane.Services
|
|||
public class JobLogService : ServiceBase, IJobLogService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public JobLogService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "JobLog"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "JobLog"); }
|
||||
}
|
||||
|
||||
public async Task<List<JobLog>> GetJobLogsAsync()
|
||||
|
|
|
@ -10,55 +10,55 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class JobService : ServiceBase, IJobService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public JobService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Job"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Job"); }
|
||||
}
|
||||
|
||||
public async Task<List<Job>> GetJobsAsync()
|
||||
{
|
||||
List<Job> Jobs = await http.GetJsonAsync<List<Job>>(apiurl);
|
||||
List<Job> Jobs = await _http.GetJsonAsync<List<Job>>(apiurl);
|
||||
return Jobs.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Job> GetJobAsync(int JobId)
|
||||
{
|
||||
return await http.GetJsonAsync<Job>(apiurl + "/" + JobId.ToString());
|
||||
return await _http.GetJsonAsync<Job>(apiurl + "/" + JobId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Job> AddJobAsync(Job Job)
|
||||
{
|
||||
return await http.PostJsonAsync<Job>(apiurl, Job);
|
||||
return await _http.PostJsonAsync<Job>(apiurl, Job);
|
||||
}
|
||||
|
||||
public async Task<Job> UpdateJobAsync(Job Job)
|
||||
{
|
||||
return await http.PutJsonAsync<Job>(apiurl + "/" + Job.JobId.ToString(), Job);
|
||||
return await _http.PutJsonAsync<Job>(apiurl + "/" + Job.JobId.ToString(), Job);
|
||||
}
|
||||
public async Task DeleteJobAsync(int JobId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + JobId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + JobId.ToString());
|
||||
}
|
||||
|
||||
public async Task StartJobAsync(int JobId)
|
||||
{
|
||||
await http.GetAsync(apiurl + "/start/" + JobId.ToString());
|
||||
await _http.GetAsync(apiurl + "/start/" + JobId.ToString());
|
||||
}
|
||||
|
||||
public async Task StopJobAsync(int JobId)
|
||||
{
|
||||
await http.GetAsync(apiurl + "/stop/" + JobId.ToString());
|
||||
await _http.GetAsync(apiurl + "/stop/" + JobId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,30 +11,30 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class LogService : ServiceBase, ILogService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public LogService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Log"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Log"); }
|
||||
}
|
||||
|
||||
public async Task<List<Log>> GetLogsAsync(int SiteId, string Level, string Function, int Rows)
|
||||
{
|
||||
return await http.GetJsonAsync<List<Log>>(apiurl + "?siteid=" + SiteId.ToString() + "&level=" + Level + "&function=" + Function + "&rows=" + Rows.ToString());
|
||||
return await _http.GetJsonAsync<List<Log>>(apiurl + "?siteid=" + SiteId.ToString() + "&level=" + Level + "&function=" + Function + "&rows=" + Rows.ToString());
|
||||
}
|
||||
|
||||
public async Task<Log> GetLogAsync(int LogId)
|
||||
{
|
||||
return await http.GetJsonAsync<Log>(apiurl + "/" + LogId.ToString());
|
||||
return await _http.GetJsonAsync<Log>(apiurl + "/" + LogId.ToString());
|
||||
}
|
||||
|
||||
public async Task Log(int? PageId, int? ModuleId, int? UserId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args)
|
||||
|
@ -47,7 +47,7 @@ namespace Oqtane.Services
|
|||
Log log = new Log();
|
||||
if (Alias == null)
|
||||
{
|
||||
log.SiteId = sitestate.Alias.SiteId;
|
||||
log.SiteId = _siteState.Alias.SiteId;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ namespace Oqtane.Services
|
|||
log.PageId = PageId;
|
||||
log.ModuleId = ModuleId;
|
||||
log.UserId = UserId;
|
||||
log.Url = NavigationManager.Uri;
|
||||
log.Url = _navigationManager.Uri;
|
||||
log.Category = category;
|
||||
log.Feature = feature;
|
||||
log.Function = Enum.GetName(typeof(LogFunction), function);
|
||||
|
@ -68,7 +68,7 @@ namespace Oqtane.Services
|
|||
log.Message = message;
|
||||
log.MessageTemplate = "";
|
||||
log.Properties = JsonSerializer.Serialize(args);
|
||||
await http.PostJsonAsync(CreateCrossTenantUrl(apiurl, Alias), log);
|
||||
await _http.PostJsonAsync(CreateCrossTenantUrl(apiurl, Alias), log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,46 +12,46 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class ModuleDefinitionService : ServiceBase, IModuleDefinitionService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public ModuleDefinitionService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "ModuleDefinition"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "ModuleDefinition"); }
|
||||
}
|
||||
|
||||
public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId)
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = await http.GetJsonAsync<List<ModuleDefinition>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<ModuleDefinition> moduledefinitions = await _http.GetJsonAsync<List<ModuleDefinition>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
return moduledefinitions.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<ModuleDefinition> GetModuleDefinitionAsync(int ModuleDefinitionId, int SiteId)
|
||||
{
|
||||
return await http.GetJsonAsync<ModuleDefinition>(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
return await _http.GetJsonAsync<ModuleDefinition>(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
}
|
||||
|
||||
public async Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition);
|
||||
await _http.PutJsonAsync(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition);
|
||||
}
|
||||
|
||||
public async Task InstallModuleDefinitionsAsync()
|
||||
{
|
||||
await http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||
await _http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||
}
|
||||
|
||||
public async Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
}
|
||||
|
||||
public async Task LoadModuleDefinitionsAsync(int SiteId)
|
||||
|
@ -73,7 +73,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync(apiurl + "/load/" + assemblyname + ".dll");
|
||||
var bytes = await _http.GetByteArrayAsync(apiurl + "/load/" + assemblyname + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(moduledefinition.AssemblyName + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync(apiurl + "/load/" + moduledefinition.AssemblyName + ".dll");
|
||||
var bytes = await _http.GetByteArrayAsync(apiurl + "/load/" + moduledefinition.AssemblyName + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,25 +10,25 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class ModuleService : ServiceBase, IModuleService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public ModuleService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Module"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Module"); }
|
||||
}
|
||||
|
||||
public async Task<List<Module>> GetModulesAsync(int SiteId)
|
||||
{
|
||||
List<Module> modules = await http.GetJsonAsync<List<Module>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<Module> modules = await _http.GetJsonAsync<List<Module>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
modules = modules
|
||||
.OrderBy(item => item.Order)
|
||||
.ToList();
|
||||
|
@ -37,32 +37,32 @@ namespace Oqtane.Services
|
|||
|
||||
public async Task<Module> GetModuleAsync(int ModuleId)
|
||||
{
|
||||
return await http.GetJsonAsync<Module>(apiurl + "/" + ModuleId.ToString());
|
||||
return await _http.GetJsonAsync<Module>(apiurl + "/" + ModuleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Module> AddModuleAsync(Module Module)
|
||||
{
|
||||
return await http.PostJsonAsync<Module>(apiurl, Module);
|
||||
return await _http.PostJsonAsync<Module>(apiurl, Module);
|
||||
}
|
||||
|
||||
public async Task<Module> UpdateModuleAsync(Module Module)
|
||||
{
|
||||
return await http.PutJsonAsync<Module>(apiurl + "/" + Module.ModuleId.ToString(), Module);
|
||||
return await _http.PutJsonAsync<Module>(apiurl + "/" + Module.ModuleId.ToString(), Module);
|
||||
}
|
||||
|
||||
public async Task DeleteModuleAsync(int ModuleId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + ModuleId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + ModuleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<bool> ImportModuleAsync(int ModuleId, string Content)
|
||||
{
|
||||
return await http.PostJsonAsync<bool>(apiurl + "/import?moduleid=" + ModuleId, Content);
|
||||
return await _http.PostJsonAsync<bool>(apiurl + "/import?moduleid=" + ModuleId, Content);
|
||||
}
|
||||
|
||||
public async Task<string> ExportModuleAsync(int ModuleId)
|
||||
{
|
||||
return await http.GetStringAsync(apiurl + "/export?moduleid=" + ModuleId.ToString());
|
||||
return await _http.GetStringAsync(apiurl + "/export?moduleid=" + ModuleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,46 +10,46 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class NotificationService : ServiceBase, INotificationService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public NotificationService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Notification"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Notification"); }
|
||||
}
|
||||
|
||||
public async Task<List<Notification>> GetNotificationsAsync(int SiteId, string Direction, int UserId)
|
||||
{
|
||||
string querystring = "?siteid=" + SiteId.ToString() + "&direction=" + Direction.ToLower() + "&userid=" + UserId.ToString();
|
||||
List<Notification> Notifications = await http.GetJsonAsync<List<Notification>>(apiurl + querystring);
|
||||
List<Notification> Notifications = await _http.GetJsonAsync<List<Notification>>(apiurl + querystring);
|
||||
return Notifications.OrderByDescending(item => item.CreatedOn).ToList();
|
||||
}
|
||||
|
||||
public async Task<Notification> GetNotificationAsync(int NotificationId)
|
||||
{
|
||||
return await http.GetJsonAsync<Notification>(apiurl + "/" + NotificationId.ToString());
|
||||
return await _http.GetJsonAsync<Notification>(apiurl + "/" + NotificationId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Notification> AddNotificationAsync(Notification Notification)
|
||||
{
|
||||
return await http.PostJsonAsync<Notification>(apiurl, Notification);
|
||||
return await _http.PostJsonAsync<Notification>(apiurl, Notification);
|
||||
}
|
||||
|
||||
public async Task<Notification> UpdateNotificationAsync(Notification Notification)
|
||||
{
|
||||
return await http.PutJsonAsync<Notification>(apiurl + "/" + Notification.NotificationId.ToString(), Notification);
|
||||
return await _http.PutJsonAsync<Notification>(apiurl + "/" + Notification.NotificationId.ToString(), Notification);
|
||||
}
|
||||
public async Task DeleteNotificationAsync(int NotificationId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + NotificationId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + NotificationId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,31 +10,31 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class PackageService : ServiceBase, IPackageService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public PackageService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Package"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Package"); }
|
||||
}
|
||||
|
||||
public async Task<List<Package>> GetPackagesAsync(string Tag)
|
||||
{
|
||||
List<Package> packages = await http.GetJsonAsync<List<Package>>(apiurl + "?tag=" + Tag);
|
||||
List<Package> packages = await _http.GetJsonAsync<List<Package>>(apiurl + "?tag=" + Tag);
|
||||
return packages.OrderByDescending(item => item.Downloads).ToList();
|
||||
}
|
||||
|
||||
public async Task DownloadPackageAsync(string PackageId, string Version, string Folder)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl + "?packageid=" + PackageId + "&version=" + Version + "&folder=" + Folder, null);
|
||||
await _http.PostJsonAsync(apiurl + "?packageid=" + PackageId + "&version=" + Version + "&folder=" + Folder, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,50 +10,50 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class PageModuleService : ServiceBase, IPageModuleService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public PageModuleService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "PageModule"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "PageModule"); }
|
||||
}
|
||||
|
||||
public async Task<PageModule> GetPageModuleAsync(int PageModuleId)
|
||||
{
|
||||
return await http.GetJsonAsync<PageModule>(apiurl + "/" + PageModuleId.ToString());
|
||||
return await _http.GetJsonAsync<PageModule>(apiurl + "/" + PageModuleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<PageModule> GetPageModuleAsync(int PageId, int ModuleId)
|
||||
{
|
||||
return await http.GetJsonAsync<PageModule>(apiurl + "/" + PageId.ToString() + "/" + ModuleId.ToString());
|
||||
return await _http.GetJsonAsync<PageModule>(apiurl + "/" + PageId.ToString() + "/" + ModuleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<PageModule> AddPageModuleAsync(PageModule PageModule)
|
||||
{
|
||||
return await http.PostJsonAsync<PageModule>(apiurl, PageModule);
|
||||
return await _http.PostJsonAsync<PageModule>(apiurl, PageModule);
|
||||
}
|
||||
|
||||
public async Task<PageModule> UpdatePageModuleAsync(PageModule PageModule)
|
||||
{
|
||||
return await http.PutJsonAsync<PageModule>(apiurl + "/" + PageModule.PageModuleId.ToString(), PageModule);
|
||||
return await _http.PutJsonAsync<PageModule>(apiurl + "/" + PageModule.PageModuleId.ToString(), PageModule);
|
||||
}
|
||||
|
||||
public async Task UpdatePageModuleOrderAsync(int PageId, string Pane)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/?pageid=" + PageId.ToString() + "&pane=" + Pane, null);
|
||||
await _http.PutJsonAsync(apiurl + "/?pageid=" + PageId.ToString() + "&pane=" + Pane, null);
|
||||
}
|
||||
|
||||
public async Task DeletePageModuleAsync(int PageModuleId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + PageModuleId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + PageModuleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,62 +11,62 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class PageService : ServiceBase, IPageService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public PageService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Page"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Page"); }
|
||||
}
|
||||
|
||||
public async Task<List<Page>> GetPagesAsync(int SiteId)
|
||||
{
|
||||
List<Page> pages = await http.GetJsonAsync<List<Page>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<Page> pages = await _http.GetJsonAsync<List<Page>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
pages = GetPagesHierarchy(pages);
|
||||
return pages;
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(int PageId)
|
||||
{
|
||||
return await http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(int PageId, int UserId)
|
||||
{
|
||||
return await http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString());
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> AddPageAsync(Page Page)
|
||||
{
|
||||
return await http.PostJsonAsync<Page>(apiurl, Page);
|
||||
return await _http.PostJsonAsync<Page>(apiurl, Page);
|
||||
}
|
||||
|
||||
public async Task<Page> AddPageAsync(int PageId, int UserId)
|
||||
{
|
||||
return await http.PostJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString(), null);
|
||||
return await _http.PostJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString(), null);
|
||||
}
|
||||
|
||||
public async Task<Page> UpdatePageAsync(Page Page)
|
||||
{
|
||||
return await http.PutJsonAsync<Page>(apiurl + "/" + Page.PageId.ToString(), Page);
|
||||
return await _http.PutJsonAsync<Page>(apiurl + "/" + Page.PageId.ToString(), Page);
|
||||
}
|
||||
|
||||
public async Task UpdatePageOrderAsync(int SiteId, int PageId, int? ParentId)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&pageid=" + PageId.ToString() + "&parentid=" + ((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||
await _http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&pageid=" + PageId.ToString() + "&parentid=" + ((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||
}
|
||||
|
||||
public async Task DeletePageAsync(int PageId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + PageId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + PageId.ToString());
|
||||
}
|
||||
|
||||
private static List<Page> GetPagesHierarchy(List<Page> Pages)
|
||||
|
|
|
@ -10,45 +10,45 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class ProfileService : ServiceBase, IProfileService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public ProfileService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Profile"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Profile"); }
|
||||
}
|
||||
|
||||
public async Task<List<Profile>> GetProfilesAsync(int SiteId)
|
||||
{
|
||||
List<Profile> Profiles = await http.GetJsonAsync<List<Profile>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<Profile> Profiles = await _http.GetJsonAsync<List<Profile>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
return Profiles.OrderBy(item => item.ViewOrder).ToList();
|
||||
}
|
||||
|
||||
public async Task<Profile> GetProfileAsync(int ProfileId)
|
||||
{
|
||||
return await http.GetJsonAsync<Profile>(apiurl + "/" + ProfileId.ToString());
|
||||
return await _http.GetJsonAsync<Profile>(apiurl + "/" + ProfileId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Profile> AddProfileAsync(Profile Profile)
|
||||
{
|
||||
return await http.PostJsonAsync<Profile>(apiurl, Profile);
|
||||
return await _http.PostJsonAsync<Profile>(apiurl, Profile);
|
||||
}
|
||||
|
||||
public async Task<Profile> UpdateProfileAsync(Profile Profile)
|
||||
{
|
||||
return await http.PutJsonAsync<Profile>(apiurl + "/" + Profile.SiteId.ToString(), Profile);
|
||||
return await _http.PutJsonAsync<Profile>(apiurl + "/" + Profile.SiteId.ToString(), Profile);
|
||||
}
|
||||
public async Task DeleteProfileAsync(int ProfileId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + ProfileId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + ProfileId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,45 +10,45 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class RoleService : ServiceBase, IRoleService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public RoleService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Role"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Role"); }
|
||||
}
|
||||
|
||||
public async Task<List<Role>> GetRolesAsync(int SiteId)
|
||||
{
|
||||
List<Role> Roles = await http.GetJsonAsync<List<Role>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<Role> Roles = await _http.GetJsonAsync<List<Role>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
return Roles.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Role> GetRoleAsync(int RoleId)
|
||||
{
|
||||
return await http.GetJsonAsync<Role>(apiurl + "/" + RoleId.ToString());
|
||||
return await _http.GetJsonAsync<Role>(apiurl + "/" + RoleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Role> AddRoleAsync(Role Role)
|
||||
{
|
||||
return await http.PostJsonAsync<Role>(apiurl, Role);
|
||||
return await _http.PostJsonAsync<Role>(apiurl, Role);
|
||||
}
|
||||
|
||||
public async Task<Role> UpdateRoleAsync(Role Role)
|
||||
{
|
||||
return await http.PutJsonAsync<Role>(apiurl + "/" + Role.RoleId.ToString(), Role);
|
||||
return await _http.PutJsonAsync<Role>(apiurl + "/" + Role.RoleId.ToString(), Role);
|
||||
}
|
||||
public async Task DeleteRoleAsync(int RoleId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + RoleId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + RoleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,20 +10,20 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class SettingService : ServiceBase, ISettingService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public SettingService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Setting"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Setting"); }
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetHostSettingsAsync()
|
||||
|
@ -99,7 +99,7 @@ namespace Oqtane.Services
|
|||
public async Task<Dictionary<string, string>> GetSettingsAsync(string EntityName, int EntityId)
|
||||
{
|
||||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||||
List<Setting> Settings = await http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||
List<Setting> Settings = await _http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||
foreach(Setting setting in Settings.OrderBy(item => item.SettingName).ToList())
|
||||
{
|
||||
dictionary.Add(setting.SettingName, setting.SettingValue);
|
||||
|
@ -109,7 +109,7 @@ namespace Oqtane.Services
|
|||
|
||||
public async Task UpdateSettingsAsync(Dictionary<string, string> Settings, string EntityName, int EntityId)
|
||||
{
|
||||
List<Setting> settings = await http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||
List<Setting> settings = await _http.GetJsonAsync<List<Setting>>(apiurl + "?entityname=" + EntityName + "&entityid=" + EntityId.ToString());
|
||||
foreach (KeyValuePair<string, string> kvp in Settings)
|
||||
{
|
||||
Setting setting = settings.Where(item => item.SettingName == kvp.Key).FirstOrDefault();
|
||||
|
@ -136,22 +136,22 @@ namespace Oqtane.Services
|
|||
|
||||
public async Task<Setting> GetSettingAsync(int SettingId)
|
||||
{
|
||||
return await http.GetJsonAsync<Setting>(apiurl + "/" + SettingId.ToString());
|
||||
return await _http.GetJsonAsync<Setting>(apiurl + "/" + SettingId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Setting> AddSettingAsync(Setting Setting)
|
||||
{
|
||||
return await http.PostJsonAsync<Setting>(apiurl, Setting);
|
||||
return await _http.PostJsonAsync<Setting>(apiurl, Setting);
|
||||
}
|
||||
|
||||
public async Task<Setting> UpdateSettingAsync(Setting Setting)
|
||||
{
|
||||
return await http.PutJsonAsync<Setting>(apiurl + "/" + Setting.SettingId.ToString(), Setting);
|
||||
return await _http.PutJsonAsync<Setting>(apiurl + "/" + Setting.SettingId.ToString(), Setting);
|
||||
}
|
||||
|
||||
public async Task DeleteSettingAsync(int SettingId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + SettingId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + SettingId.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,46 +10,46 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class SiteService : ServiceBase, ISiteService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public SiteService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Site"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Site"); }
|
||||
}
|
||||
|
||||
public async Task<List<Site>> GetSitesAsync(Alias Alias)
|
||||
{
|
||||
List<Site> sites = await http.GetJsonAsync<List<Site>>(CreateCrossTenantUrl(apiurl, Alias));
|
||||
List<Site> sites = await _http.GetJsonAsync<List<Site>>(CreateCrossTenantUrl(apiurl, Alias));
|
||||
return sites.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Site> GetSiteAsync(int SiteId, Alias Alias)
|
||||
{
|
||||
return await http.GetJsonAsync<Site>(CreateCrossTenantUrl(apiurl + "/" + SiteId.ToString(), Alias));
|
||||
return await _http.GetJsonAsync<Site>(CreateCrossTenantUrl(apiurl + "/" + SiteId.ToString(), Alias));
|
||||
}
|
||||
|
||||
public async Task<Site> AddSiteAsync(Site Site, Alias Alias)
|
||||
{
|
||||
return await http.PostJsonAsync<Site>(CreateCrossTenantUrl(apiurl, Alias), Site);
|
||||
return await _http.PostJsonAsync<Site>(CreateCrossTenantUrl(apiurl, Alias), Site);
|
||||
}
|
||||
|
||||
public async Task<Site> UpdateSiteAsync(Site Site, Alias Alias)
|
||||
{
|
||||
return await http.PutJsonAsync<Site>(CreateCrossTenantUrl(apiurl + "/" + Site.SiteId.ToString(), Alias), Site);
|
||||
return await _http.PutJsonAsync<Site>(CreateCrossTenantUrl(apiurl + "/" + Site.SiteId.ToString(), Alias), Site);
|
||||
}
|
||||
|
||||
public async Task DeleteSiteAsync(int SiteId, Alias Alias)
|
||||
{
|
||||
await http.DeleteAsync(CreateCrossTenantUrl(apiurl + "/" + SiteId.ToString(), Alias));
|
||||
await _http.DeleteAsync(CreateCrossTenantUrl(apiurl + "/" + SiteId.ToString(), Alias));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,46 +10,46 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class TenantService : ServiceBase, ITenantService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public TenantService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Tenant"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Tenant"); }
|
||||
}
|
||||
|
||||
public async Task<List<Tenant>> GetTenantsAsync()
|
||||
{
|
||||
List<Tenant> tenants = await http.GetJsonAsync<List<Tenant>>(apiurl);
|
||||
List<Tenant> tenants = await _http.GetJsonAsync<List<Tenant>>(apiurl);
|
||||
return tenants.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Tenant> GetTenantAsync(int TenantId)
|
||||
{
|
||||
return await http.GetJsonAsync<Tenant>(apiurl + "/" + TenantId.ToString());
|
||||
return await _http.GetJsonAsync<Tenant>(apiurl + "/" + TenantId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Tenant> AddTenantAsync(Tenant Tenant)
|
||||
{
|
||||
return await http.PostJsonAsync<Tenant>(apiurl, Tenant);
|
||||
return await _http.PostJsonAsync<Tenant>(apiurl, Tenant);
|
||||
}
|
||||
|
||||
public async Task<Tenant> UpdateTenantAsync(Tenant Tenant)
|
||||
{
|
||||
return await http.PutJsonAsync<Tenant>(apiurl + "/" + Tenant.TenantId.ToString(), Tenant);
|
||||
return await _http.PutJsonAsync<Tenant>(apiurl + "/" + Tenant.TenantId.ToString(), Tenant);
|
||||
}
|
||||
|
||||
public async Task DeleteTenantAsync(int TenantId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + TenantId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + TenantId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,25 +12,25 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class ThemeService : ServiceBase, IThemeService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public ThemeService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Theme"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Theme"); }
|
||||
}
|
||||
|
||||
public async Task<List<Theme>> GetThemesAsync()
|
||||
{
|
||||
List<Theme> themes = await http.GetJsonAsync<List<Theme>>(apiurl);
|
||||
List<Theme> themes = await _http.GetJsonAsync<List<Theme>>(apiurl);
|
||||
|
||||
// get list of loaded assemblies
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
@ -45,7 +45,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync(apiurl + "/load/" + assemblyname + ".dll");
|
||||
var bytes = await _http.GetByteArrayAsync(apiurl + "/load/" + assemblyname + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(theme.AssemblyName + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync(apiurl + "/load/" + theme.AssemblyName + ".dll");
|
||||
var bytes = await _http.GetByteArrayAsync(apiurl + "/load/" + theme.AssemblyName + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -105,12 +105,12 @@ namespace Oqtane.Services
|
|||
|
||||
public async Task InstallThemesAsync()
|
||||
{
|
||||
await http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||
await _http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||
}
|
||||
|
||||
public async Task DeleteThemeAsync(string ThemeName)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + ThemeName);
|
||||
await _http.DeleteAsync(apiurl + "/" + ThemeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,45 +10,45 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class UserRoleService : ServiceBase, IUserRoleService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public UserRoleService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "UserRole"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "UserRole"); }
|
||||
}
|
||||
|
||||
public async Task<List<UserRole>> GetUserRolesAsync(int SiteId)
|
||||
{
|
||||
return await http.GetJsonAsync<List<UserRole>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
return await _http.GetJsonAsync<List<UserRole>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
}
|
||||
|
||||
public async Task<UserRole> GetUserRoleAsync(int UserRoleId)
|
||||
{
|
||||
return await http.GetJsonAsync<UserRole>(apiurl + "/" + UserRoleId.ToString());
|
||||
return await _http.GetJsonAsync<UserRole>(apiurl + "/" + UserRoleId.ToString());
|
||||
}
|
||||
|
||||
public async Task<UserRole> AddUserRoleAsync(UserRole UserRole)
|
||||
{
|
||||
return await http.PostJsonAsync<UserRole>(apiurl, UserRole);
|
||||
return await _http.PostJsonAsync<UserRole>(apiurl, UserRole);
|
||||
}
|
||||
|
||||
public async Task<UserRole> UpdateUserRoleAsync(UserRole UserRole)
|
||||
{
|
||||
return await http.PutJsonAsync<UserRole>(apiurl + "/" + UserRole.UserRoleId.ToString(), UserRole);
|
||||
return await _http.PutJsonAsync<UserRole>(apiurl + "/" + UserRole.UserRoleId.ToString(), UserRole);
|
||||
}
|
||||
|
||||
public async Task DeleteUserRoleAsync(int UserRoleId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + UserRoleId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + UserRoleId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,37 +8,37 @@ namespace Oqtane.Services
|
|||
{
|
||||
public class UserService : ServiceBase, IUserService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly SiteState sitestate;
|
||||
private readonly NavigationManager NavigationManager;
|
||||
private readonly HttpClient _http;
|
||||
private readonly SiteState _siteState;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
|
||||
public UserService(HttpClient http, SiteState sitestate, NavigationManager NavigationManager)
|
||||
{
|
||||
this.http = http;
|
||||
this.sitestate = sitestate;
|
||||
this.NavigationManager = NavigationManager;
|
||||
this._http = http;
|
||||
this._siteState = sitestate;
|
||||
this._navigationManager = NavigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
{
|
||||
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "User"); }
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "User"); }
|
||||
}
|
||||
|
||||
public async Task<User> GetUserAsync(int UserId, int SiteId)
|
||||
{
|
||||
return await http.GetJsonAsync<User>(apiurl + "/" + UserId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
return await _http.GetJsonAsync<User>(apiurl + "/" + UserId.ToString() + "?siteid=" + SiteId.ToString());
|
||||
}
|
||||
|
||||
public async Task<User> GetUserAsync(string Username, int SiteId)
|
||||
{
|
||||
return await http.GetJsonAsync<User>(apiurl + "/name/" + Username + "?siteid=" + SiteId.ToString());
|
||||
return await _http.GetJsonAsync<User>(apiurl + "/name/" + Username + "?siteid=" + SiteId.ToString());
|
||||
}
|
||||
|
||||
public async Task<User> AddUserAsync(User User)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await http.PostJsonAsync<User>(apiurl, User);
|
||||
return await _http.PostJsonAsync<User>(apiurl, User);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace Oqtane.Services
|
|||
{
|
||||
try
|
||||
{
|
||||
return await http.PostJsonAsync<User>(CreateCrossTenantUrl(apiurl, Alias), User);
|
||||
return await _http.PostJsonAsync<User>(CreateCrossTenantUrl(apiurl, Alias), User);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -60,37 +60,37 @@ namespace Oqtane.Services
|
|||
|
||||
public async Task<User> UpdateUserAsync(User User)
|
||||
{
|
||||
return await http.PutJsonAsync<User>(apiurl + "/" + User.UserId.ToString(), User);
|
||||
return await _http.PutJsonAsync<User>(apiurl + "/" + User.UserId.ToString(), User);
|
||||
}
|
||||
public async Task DeleteUserAsync(int UserId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + UserId.ToString());
|
||||
await _http.DeleteAsync(apiurl + "/" + UserId.ToString());
|
||||
}
|
||||
|
||||
public async Task<User> LoginUserAsync(User User, bool SetCookie, bool IsPersistent)
|
||||
{
|
||||
return await http.PostJsonAsync<User>(apiurl + "/login?setcookie=" + SetCookie.ToString() + "&persistent=" + IsPersistent.ToString(), User);
|
||||
return await _http.PostJsonAsync<User>(apiurl + "/login?setcookie=" + SetCookie.ToString() + "&persistent=" + IsPersistent.ToString(), User);
|
||||
}
|
||||
|
||||
public async Task LogoutUserAsync(User User)
|
||||
{
|
||||
// best practices recommend post is preferrable to get for logout
|
||||
await http.PostJsonAsync(apiurl + "/logout", User);
|
||||
await _http.PostJsonAsync(apiurl + "/logout", User);
|
||||
}
|
||||
|
||||
public async Task<User> VerifyEmailAsync(User User, string Token)
|
||||
{
|
||||
return await http.PostJsonAsync<User>(apiurl + "/verify?token=" + Token, User);
|
||||
return await _http.PostJsonAsync<User>(apiurl + "/verify?token=" + Token, User);
|
||||
}
|
||||
|
||||
public async Task ForgotPasswordAsync(User User)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl + "/forgot", User);
|
||||
await _http.PostJsonAsync(apiurl + "/forgot", User);
|
||||
}
|
||||
|
||||
public async Task<User> ResetPasswordAsync(User User, string Token)
|
||||
{
|
||||
return await http.PostJsonAsync<User>(apiurl + "/reset?token=" + Token, User);
|
||||
return await _http.PostJsonAsync<User>(apiurl + "/reset?token=" + Token, User);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,18 +7,18 @@ namespace Oqtane.Shared
|
|||
{
|
||||
public class Interop
|
||||
{
|
||||
private readonly IJSRuntime jsRuntime;
|
||||
private readonly IJSRuntime _jsRuntime;
|
||||
|
||||
public Interop(IJSRuntime jsRuntime)
|
||||
{
|
||||
this.jsRuntime = jsRuntime;
|
||||
this._jsRuntime = jsRuntime;
|
||||
}
|
||||
|
||||
public Task SetCookie(string name, string value, int days)
|
||||
{
|
||||
try
|
||||
{
|
||||
jsRuntime.InvokeAsync<string>(
|
||||
_jsRuntime.InvokeAsync<string>(
|
||||
"interop.setCookie",
|
||||
name, value, days);
|
||||
return Task.CompletedTask;
|
||||
|
@ -33,7 +33,7 @@ namespace Oqtane.Shared
|
|||
{
|
||||
try
|
||||
{
|
||||
return jsRuntime.InvokeAsync<string>(
|
||||
return _jsRuntime.InvokeAsync<string>(
|
||||
"interop.getCookie",
|
||||
name);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace Oqtane.Shared
|
|||
{
|
||||
try
|
||||
{
|
||||
jsRuntime.InvokeAsync<string>(
|
||||
_jsRuntime.InvokeAsync<string>(
|
||||
"interop.includeCSS",
|
||||
id, url);
|
||||
return Task.CompletedTask;
|
||||
|
@ -62,7 +62,7 @@ namespace Oqtane.Shared
|
|||
{
|
||||
try
|
||||
{
|
||||
return jsRuntime.InvokeAsync<string>(
|
||||
return _jsRuntime.InvokeAsync<string>(
|
||||
"interop.getElementByName",
|
||||
name);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace Oqtane.Shared
|
|||
{
|
||||
try
|
||||
{
|
||||
jsRuntime.InvokeAsync<string>(
|
||||
_jsRuntime.InvokeAsync<string>(
|
||||
"interop.submitForm",
|
||||
path, fields);
|
||||
return Task.CompletedTask;
|
||||
|
@ -91,7 +91,7 @@ namespace Oqtane.Shared
|
|||
{
|
||||
try
|
||||
{
|
||||
return jsRuntime.InvokeAsync<string[]>(
|
||||
return _jsRuntime.InvokeAsync<string[]>(
|
||||
"interop.getFiles",
|
||||
id);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ namespace Oqtane.Shared
|
|||
{
|
||||
try
|
||||
{
|
||||
jsRuntime.InvokeAsync<string>(
|
||||
_jsRuntime.InvokeAsync<string>(
|
||||
"interop.uploadFiles",
|
||||
posturl, folder, id);
|
||||
return Task.CompletedTask;
|
||||
|
|
|
@ -14,13 +14,13 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class AliasController : Controller
|
||||
{
|
||||
private readonly IAliasRepository Aliases;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IAliasRepository _aliases;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public AliasController(IAliasRepository Aliases, ILogManager logger)
|
||||
{
|
||||
this.Aliases = Aliases;
|
||||
this.logger = logger;
|
||||
this._aliases = Aliases;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
|
@ -28,7 +28,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public IEnumerable<Alias> Get()
|
||||
{
|
||||
return Aliases.GetAliases();
|
||||
return _aliases.GetAliases();
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
|
@ -36,7 +36,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public Alias Get(int id)
|
||||
{
|
||||
return Aliases.GetAlias(id);
|
||||
return _aliases.GetAlias(id);
|
||||
}
|
||||
|
||||
// GET api/<controller>/name/localhost:12345
|
||||
|
@ -44,7 +44,7 @@ namespace Oqtane.Controllers
|
|||
public Alias Get(string name)
|
||||
{
|
||||
name = WebUtility.UrlDecode(name);
|
||||
List<Alias> aliases = Aliases.GetAliases().ToList();
|
||||
List<Alias> aliases = _aliases.GetAliases().ToList();
|
||||
Alias alias = null;
|
||||
alias = aliases.Where(item => item.Name == name).FirstOrDefault();
|
||||
if (alias == null && name.Contains("/"))
|
||||
|
@ -67,8 +67,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Alias = Aliases.AddAlias(Alias);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Alias Added {Alias}", Alias);
|
||||
Alias = _aliases.AddAlias(Alias);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Alias Added {Alias}", Alias);
|
||||
}
|
||||
return Alias;
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Alias = Aliases.UpdateAlias(Alias);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Alias Updated {Alias}", Alias);
|
||||
Alias = _aliases.UpdateAlias(Alias);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Alias Updated {Alias}", Alias);
|
||||
}
|
||||
return Alias;
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Aliases.DeleteAlias(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Alias Deleted {AliasId}", id);
|
||||
_aliases.DeleteAlias(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Alias Deleted {AliasId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,21 +20,21 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class FileController : Controller
|
||||
{
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly IFileRepository Files;
|
||||
private readonly IFolderRepository Folders;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ITenantResolver Tenants;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
private readonly IFileRepository _files;
|
||||
private readonly IFolderRepository _folders;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ITenantResolver _tenants;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public FileController(IWebHostEnvironment environment, IFileRepository Files, IFolderRepository Folders, IUserPermissions UserPermissions, ITenantResolver Tenants, ILogManager logger)
|
||||
{
|
||||
this.environment = environment;
|
||||
this.Files = Files;
|
||||
this.Folders = Folders;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.Tenants = Tenants;
|
||||
this.logger = logger;
|
||||
this._environment = environment;
|
||||
this._files = Files;
|
||||
this._folders = Folders;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._tenants = Tenants;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?folder=x
|
||||
|
@ -45,10 +45,10 @@ namespace Oqtane.Controllers
|
|||
int folderid;
|
||||
if (int.TryParse(folder, out folderid))
|
||||
{
|
||||
Folder Folder = Folders.GetFolder(folderid);
|
||||
if (Folder != null && UserPermissions.IsAuthorized(User, "Browse", Folder.Permissions))
|
||||
Folder Folder = _folders.GetFolder(folderid);
|
||||
if (Folder != null && _userPermissions.IsAuthorized(User, "Browse", Folder.Permissions))
|
||||
{
|
||||
files = Files.GetFiles(folderid).ToList();
|
||||
files = _files.GetFiles(folderid).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -72,14 +72,14 @@ namespace Oqtane.Controllers
|
|||
[HttpGet("{id}")]
|
||||
public Models.File Get(int id)
|
||||
{
|
||||
Models.File file = Files.GetFile(id);
|
||||
if (UserPermissions.IsAuthorized(User, "View", file.Folder.Permissions))
|
||||
Models.File file = _files.GetFile(id);
|
||||
if (_userPermissions.IsAuthorized(User, "View", file.Folder.Permissions))
|
||||
{
|
||||
return file;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access File {File}", file);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access File {File}", file);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -90,14 +90,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Models.File Put(int id, [FromBody] Models.File File)
|
||||
{
|
||||
if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Folder", File.Folder.FolderId, "Edit"))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Folder", File.Folder.FolderId, "Edit"))
|
||||
{
|
||||
File = Files.UpdateFile(File);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "File Updated {File}", File);
|
||||
File = _files.UpdateFile(File);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "File Updated {File}", File);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update File {File}", File);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update File {File}", File);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
File = null;
|
||||
}
|
||||
|
@ -109,21 +109,21 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Models.File File = Files.GetFile(id);
|
||||
if (UserPermissions.IsAuthorized(User, "Folder", File.Folder.FolderId, "Edit"))
|
||||
Models.File File = _files.GetFile(id);
|
||||
if (_userPermissions.IsAuthorized(User, "Folder", File.Folder.FolderId, "Edit"))
|
||||
{
|
||||
Files.DeleteFile(id);
|
||||
_files.DeleteFile(id);
|
||||
|
||||
string filepath = Path.Combine(GetFolderPath(File.Folder) + File.Name);
|
||||
if (System.IO.File.Exists(filepath))
|
||||
{
|
||||
System.IO.File.Delete(filepath);
|
||||
}
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "File Deleted {File}", File);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "File Deleted {File}", File);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete File {FileId}", id);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete File {FileId}", id);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ namespace Oqtane.Controllers
|
|||
public Models.File UploadFile(string url, string folderid)
|
||||
{
|
||||
Models.File file = null;
|
||||
Folder folder = Folders.GetFolder(int.Parse(folderid));
|
||||
if (folder != null && UserPermissions.IsAuthorized(User, "Edit", folder.Permissions))
|
||||
Folder folder = _folders.GetFolder(int.Parse(folderid));
|
||||
if (folder != null && _userPermissions.IsAuthorized(User, "Edit", folder.Permissions))
|
||||
{
|
||||
string folderpath = GetFolderPath(folder);
|
||||
CreateDirectory(folderpath);
|
||||
|
@ -151,21 +151,21 @@ namespace Oqtane.Controllers
|
|||
System.IO.File.Delete(folderpath + filename);
|
||||
}
|
||||
client.DownloadFile(url, folderpath + filename);
|
||||
Files.AddFile(CreateFile(filename, folder.FolderId, folderpath + filename));
|
||||
_files.AddFile(CreateFile(filename, folder.FolderId, folderpath + filename));
|
||||
}
|
||||
catch
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "File Could Not Be Downloaded From Url {Url}", url);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "File Could Not Be Downloaded From Url {Url}", url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "File Could Not Be Downloaded From Url Due To Its File Extension {Url}", url);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "File Could Not Be Downloaded From Url Due To Its File Extension {Url}", url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Download File {Url} {FolderId}", url, folderid);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Download File {Url} {FolderId}", url, folderid);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
file = null;
|
||||
}
|
||||
|
@ -182,8 +182,8 @@ namespace Oqtane.Controllers
|
|||
int folderid = -1;
|
||||
if (int.TryParse(folder, out folderid))
|
||||
{
|
||||
Folder Folder = Folders.GetFolder(folderid);
|
||||
if (Folder != null && UserPermissions.IsAuthorized(User, "Edit", Folder.Permissions))
|
||||
Folder Folder = _folders.GetFolder(folderid);
|
||||
if (Folder != null && _userPermissions.IsAuthorized(User, "Edit", Folder.Permissions))
|
||||
{
|
||||
folderpath = GetFolderPath(Folder);
|
||||
}
|
||||
|
@ -205,12 +205,12 @@ namespace Oqtane.Controllers
|
|||
string upload = await MergeFile(folderpath, file.FileName);
|
||||
if (upload != "" && folderid != -1)
|
||||
{
|
||||
Files.AddFile(CreateFile(upload, folderid, folderpath + upload));
|
||||
_files.AddFile(CreateFile(upload, folderid, folderpath + upload));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Upload File {Folder} {File}", folder, file);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Upload File {Folder} {File}", folder, file);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
// rename file now that the entire process is completed
|
||||
System.IO.File.Move(Path.Combine(folder, filename + ".tmp"), Path.Combine(folder, filename));
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "File Uploaded {File}", Path.Combine(folder, filename));
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "File Uploaded {File}", Path.Combine(folder, filename));
|
||||
}
|
||||
merged = filename;
|
||||
}
|
||||
|
@ -333,8 +333,8 @@ namespace Oqtane.Controllers
|
|||
[HttpGet("download/{id}")]
|
||||
public IActionResult Download(int id)
|
||||
{
|
||||
Models.File file = Files.GetFile(id);
|
||||
if (file != null && UserPermissions.IsAuthorized(User, "View", file.Folder.Permissions))
|
||||
Models.File file = _files.GetFile(id);
|
||||
if (file != null && _userPermissions.IsAuthorized(User, "View", file.Folder.Permissions))
|
||||
{
|
||||
string filepath = GetFolderPath(file.Folder) + file.Name;
|
||||
if (System.IO.File.Exists(filepath))
|
||||
|
@ -344,14 +344,14 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "File Does Not Exist {File}", file);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "File Does Not Exist {File}", file);
|
||||
HttpContext.Response.StatusCode = 404;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access File {FileId}", id);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access File {FileId}", id);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -359,12 +359,12 @@ namespace Oqtane.Controllers
|
|||
|
||||
private string GetFolderPath(Folder folder)
|
||||
{
|
||||
return environment.ContentRootPath + "\\Content\\Tenants\\" + Tenants.GetTenant().TenantId.ToString() + "\\Sites\\" + folder.SiteId.ToString() + "\\" + folder.Path;
|
||||
return _environment.ContentRootPath + "\\Content\\Tenants\\" + _tenants.GetTenant().TenantId.ToString() + "\\Sites\\" + folder.SiteId.ToString() + "\\" + folder.Path;
|
||||
}
|
||||
|
||||
private string GetFolderPath(string folder)
|
||||
{
|
||||
return Path.Combine(environment.WebRootPath, folder);
|
||||
return Path.Combine(_environment.WebRootPath, folder);
|
||||
}
|
||||
|
||||
private void CreateDirectory(string folderpath)
|
||||
|
|
|
@ -13,15 +13,15 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class FolderController : Controller
|
||||
{
|
||||
private readonly IFolderRepository Folders;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IFolderRepository _folders;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public FolderController(IFolderRepository Folders, IUserPermissions UserPermissions, ILogManager logger)
|
||||
{
|
||||
this.Folders = Folders;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.logger = logger;
|
||||
this._folders = Folders;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
|
@ -29,9 +29,9 @@ namespace Oqtane.Controllers
|
|||
public IEnumerable<Folder> Get(string siteid)
|
||||
{
|
||||
List<Folder> folders = new List<Folder>();
|
||||
foreach(Folder folder in Folders.GetFolders(int.Parse(siteid)))
|
||||
foreach(Folder folder in _folders.GetFolders(int.Parse(siteid)))
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "Browse", folder.Permissions))
|
||||
if (_userPermissions.IsAuthorized(User, "Browse", folder.Permissions))
|
||||
{
|
||||
folders.Add(folder);
|
||||
}
|
||||
|
@ -43,14 +43,14 @@ namespace Oqtane.Controllers
|
|||
[HttpGet("{id}")]
|
||||
public Folder Get(int id)
|
||||
{
|
||||
Folder folder = Folders.GetFolder(id);
|
||||
if (UserPermissions.IsAuthorized(User, "Browse", folder.Permissions))
|
||||
Folder folder = _folders.GetFolder(id);
|
||||
if (_userPermissions.IsAuthorized(User, "Browse", folder.Permissions))
|
||||
{
|
||||
return folder;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Folder {Folder}", folder);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Folder {Folder}", folder);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -66,25 +66,25 @@ namespace Oqtane.Controllers
|
|||
string permissions;
|
||||
if (Folder.ParentId != null)
|
||||
{
|
||||
permissions = Folders.GetFolder(Folder.ParentId.Value).Permissions;
|
||||
permissions = _folders.GetFolder(Folder.ParentId.Value).Permissions;
|
||||
}
|
||||
else
|
||||
{
|
||||
permissions = UserSecurity.SetPermissionStrings(new List<PermissionString> { new PermissionString { PermissionName = "Edit", Permissions = Constants.AdminRole } });
|
||||
}
|
||||
if (UserPermissions.IsAuthorized(User, "Edit", permissions))
|
||||
if (_userPermissions.IsAuthorized(User, "Edit", permissions))
|
||||
{
|
||||
if (string.IsNullOrEmpty(Folder.Path) && Folder.ParentId != null)
|
||||
{
|
||||
Folder parent = Folders.GetFolder(Folder.ParentId.Value);
|
||||
Folder parent = _folders.GetFolder(Folder.ParentId.Value);
|
||||
Folder.Path = parent.Path + Folder.Name + "\\";
|
||||
}
|
||||
Folder = Folders.AddFolder(Folder);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Folder Added {Folder}", Folder);
|
||||
Folder = _folders.AddFolder(Folder);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Folder Added {Folder}", Folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Folder {Folder}", Folder);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Folder {Folder}", Folder);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Folder = null;
|
||||
}
|
||||
|
@ -97,19 +97,19 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Folder Put(int id, [FromBody] Folder Folder)
|
||||
{
|
||||
if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Folder", Folder.FolderId, "Edit"))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Folder", Folder.FolderId, "Edit"))
|
||||
{
|
||||
if (string.IsNullOrEmpty(Folder.Path) && Folder.ParentId != null)
|
||||
{
|
||||
Folder parent = Folders.GetFolder(Folder.ParentId.Value);
|
||||
Folder parent = _folders.GetFolder(Folder.ParentId.Value);
|
||||
Folder.Path = parent.Path + Folder.Name + "\\";
|
||||
}
|
||||
Folder = Folders.UpdateFolder(Folder);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Updated {Folder}", Folder);
|
||||
Folder = _folders.UpdateFolder(Folder);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Updated {Folder}", Folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Folder {Folder}", Folder);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Folder {Folder}", Folder);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Folder = null;
|
||||
}
|
||||
|
@ -121,24 +121,24 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Put(int siteid, int folderid, int? parentid)
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "Folder", folderid, "Edit"))
|
||||
if (_userPermissions.IsAuthorized(User, "Folder", folderid, "Edit"))
|
||||
{
|
||||
int order = 1;
|
||||
List<Folder> folders = Folders.GetFolders(siteid).ToList();
|
||||
List<Folder> folders = _folders.GetFolders(siteid).ToList();
|
||||
foreach (Folder folder in folders.Where(item => item.ParentId == parentid).OrderBy(item => item.Order))
|
||||
{
|
||||
if (folder.Order != order)
|
||||
{
|
||||
folder.Order = order;
|
||||
Folders.UpdateFolder(folder);
|
||||
_folders.UpdateFolder(folder);
|
||||
}
|
||||
order += 2;
|
||||
}
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Order Updated {SiteId} {FolderId} {ParentId}", siteid, folderid, parentid);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Folder Order Updated {SiteId} {FolderId} {ParentId}", siteid, folderid, parentid);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Folder Order {SiteId} {FolderId} {ParentId}", siteid, folderid, parentid);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Folder Order {SiteId} {FolderId} {ParentId}", siteid, folderid, parentid);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
@ -148,14 +148,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "Folder", id, "Edit"))
|
||||
if (_userPermissions.IsAuthorized(User, "Folder", id, "Edit"))
|
||||
{
|
||||
Folders.DeleteFolder(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id);
|
||||
_folders.DeleteFolder(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Folder {FolderId}", id);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Folder {FolderId}", id);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class InstallationController : Controller
|
||||
{
|
||||
private readonly IConfigurationRoot Config;
|
||||
private readonly IInstallationManager InstallationManager;
|
||||
private readonly IConfigurationRoot _config;
|
||||
private readonly IInstallationManager _installationManager;
|
||||
|
||||
public InstallationController(IConfigurationRoot Config, IInstallationManager InstallationManager)
|
||||
{
|
||||
this.Config = Config;
|
||||
this.InstallationManager = InstallationManager;
|
||||
this._config = Config;
|
||||
this._installationManager = InstallationManager;
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -37,7 +37,7 @@ namespace Oqtane.Controllers
|
|||
if (ModelState.IsValid)
|
||||
{
|
||||
bool master = false;
|
||||
string defaultconnectionstring = Config.GetConnectionString("DefaultConnection");
|
||||
string defaultconnectionstring = _config.GetConnectionString("DefaultConnection");
|
||||
if (string.IsNullOrEmpty(defaultconnectionstring) || connectionstring == defaultconnectionstring)
|
||||
{
|
||||
master = true;
|
||||
|
@ -158,7 +158,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
writer.WriteLine(config);
|
||||
}
|
||||
Config.Reload();
|
||||
_config.Reload();
|
||||
}
|
||||
response.Success = true;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ namespace Oqtane.Controllers
|
|||
var response = new GenericResponse { Success = false, Message = "" };
|
||||
|
||||
string datadirectory = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
|
||||
string connectionString = Config.GetConnectionString("DefaultConnection");
|
||||
string connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
connectionString = connectionString.Replace("|DataDirectory|", datadirectory);
|
||||
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
|
@ -286,7 +286,7 @@ namespace Oqtane.Controllers
|
|||
public GenericResponse Upgrade()
|
||||
{
|
||||
var response = new GenericResponse { Success = true, Message = "" };
|
||||
InstallationManager.UpgradeFramework();
|
||||
_installationManager.UpgradeFramework();
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class JobController : Controller
|
||||
{
|
||||
private readonly IJobRepository Jobs;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IServiceProvider ServiceProvider;
|
||||
private readonly IJobRepository _jobs;
|
||||
private readonly ILogManager _logger;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public JobController(IJobRepository Jobs, ILogManager logger, IServiceProvider ServiceProvider)
|
||||
{
|
||||
this.Jobs = Jobs;
|
||||
this.logger = logger;
|
||||
this.ServiceProvider = ServiceProvider;
|
||||
this._jobs = Jobs;
|
||||
this._logger = logger;
|
||||
this._serviceProvider = ServiceProvider;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
|
@ -30,7 +30,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public IEnumerable<Job> Get()
|
||||
{
|
||||
return Jobs.GetJobs();
|
||||
return _jobs.GetJobs();
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
|
@ -38,7 +38,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Job Get(int id)
|
||||
{
|
||||
return Jobs.GetJob(id);
|
||||
return _jobs.GetJob(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -48,8 +48,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Job = Jobs.AddJob(Job);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Added {Job}", Job);
|
||||
Job = _jobs.AddJob(Job);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Added {Job}", Job);
|
||||
}
|
||||
return Job;
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Job = Jobs.UpdateJob(Job);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Job Updated {Job}", Job);
|
||||
Job = _jobs.UpdateJob(Job);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Job Updated {Job}", Job);
|
||||
}
|
||||
return Job;
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Jobs.DeleteJob(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Job Deleted {JobId}", id);
|
||||
_jobs.DeleteJob(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Job Deleted {JobId}", id);
|
||||
}
|
||||
|
||||
// GET api/<controller>/start
|
||||
|
@ -81,11 +81,11 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Start(int id)
|
||||
{
|
||||
Job job = Jobs.GetJob(id);
|
||||
Job job = _jobs.GetJob(id);
|
||||
Type jobtype = Type.GetType(job.JobType);
|
||||
if (jobtype != null)
|
||||
{
|
||||
var jobobject = ActivatorUtilities.CreateInstance(ServiceProvider, jobtype);
|
||||
var jobobject = ActivatorUtilities.CreateInstance(_serviceProvider, jobtype);
|
||||
((IHostedService)jobobject).StartAsync(new System.Threading.CancellationToken());
|
||||
}
|
||||
}
|
||||
|
@ -95,11 +95,11 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Stop(int id)
|
||||
{
|
||||
Job job = Jobs.GetJob(id);
|
||||
Job job = _jobs.GetJob(id);
|
||||
Type jobtype = Type.GetType(job.JobType);
|
||||
if (jobtype != null)
|
||||
{
|
||||
var jobobject = ActivatorUtilities.CreateInstance(ServiceProvider, jobtype);
|
||||
var jobobject = ActivatorUtilities.CreateInstance(_serviceProvider, jobtype);
|
||||
((IHostedService)jobobject).StopAsync(new System.Threading.CancellationToken());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class JobLogController : Controller
|
||||
{
|
||||
private readonly IJobLogRepository JobLogs;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IJobLogRepository _jobLogs;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public JobLogController(IJobLogRepository JobLogs, ILogManager logger)
|
||||
{
|
||||
this.JobLogs = JobLogs;
|
||||
this.logger = logger;
|
||||
this._jobLogs = JobLogs;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
|
@ -25,7 +25,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public IEnumerable<JobLog> Get()
|
||||
{
|
||||
return JobLogs.GetJobLogs();
|
||||
return _jobLogs.GetJobLogs();
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
|
@ -33,7 +33,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public JobLog Get(int id)
|
||||
{
|
||||
return JobLogs.GetJobLog(id);
|
||||
return _jobLogs.GetJobLog(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -43,8 +43,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
JobLog = JobLogs.AddJobLog(JobLog);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Log Added {JobLog}", JobLog);
|
||||
JobLog = _jobLogs.AddJobLog(JobLog);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Job Log Added {JobLog}", JobLog);
|
||||
}
|
||||
return JobLog;
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
JobLog = JobLogs.UpdateJobLog(JobLog);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Job Log Updated {JobLog}", JobLog);
|
||||
JobLog = _jobLogs.UpdateJobLog(JobLog);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Job Log Updated {JobLog}", JobLog);
|
||||
}
|
||||
return JobLog;
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
JobLogs.DeleteJobLog(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Job Log Deleted {JobLogId}", id);
|
||||
_jobLogs.DeleteJobLog(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Job Log Deleted {JobLogId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class LogController : Controller
|
||||
{
|
||||
private readonly ILogManager Logger;
|
||||
private readonly ILogRepository Logs;
|
||||
private readonly ILogManager _ogger;
|
||||
private readonly ILogRepository _logs;
|
||||
|
||||
public LogController(ILogManager Logger, ILogRepository Logs)
|
||||
{
|
||||
this.Logger = Logger;
|
||||
this.Logs = Logs;
|
||||
this._ogger = Logger;
|
||||
this._logs = Logs;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x&level=y&function=z&rows=50
|
||||
|
@ -26,7 +26,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public IEnumerable<Log> Get(string siteid, string level, string function, string rows)
|
||||
{
|
||||
return Logs.GetLogs(int.Parse(siteid), level, function, int.Parse(rows));
|
||||
return _logs.GetLogs(int.Parse(siteid), level, function, int.Parse(rows));
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
|
@ -34,7 +34,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public Log Get(int id)
|
||||
{
|
||||
return Logs.GetLog(id);
|
||||
return _logs.GetLog(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -43,7 +43,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Logger.Log(Log);
|
||||
_ogger.Log(Log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,30 +14,30 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class ModuleController : Controller
|
||||
{
|
||||
private readonly IModuleRepository Modules;
|
||||
private readonly IPageModuleRepository PageModules;
|
||||
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IModuleRepository _modules;
|
||||
private readonly IPageModuleRepository _pageModules;
|
||||
private readonly IModuleDefinitionRepository _moduleDefinitions;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public ModuleController(IModuleRepository Modules, IPageModuleRepository PageModules, IModuleDefinitionRepository ModuleDefinitions, IUserPermissions UserPermissions, ILogManager logger)
|
||||
{
|
||||
this.Modules = Modules;
|
||||
this.PageModules = PageModules;
|
||||
this.ModuleDefinitions = ModuleDefinitions;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.logger = logger;
|
||||
this._modules = Modules;
|
||||
this._pageModules = PageModules;
|
||||
this._moduleDefinitions = ModuleDefinitions;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
[HttpGet]
|
||||
public IEnumerable<Models.Module> Get(string siteid)
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(int.Parse(siteid)).ToList();
|
||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(int.Parse(siteid)).ToList();
|
||||
List<Models.Module> modules = new List<Models.Module>();
|
||||
foreach (PageModule pagemodule in PageModules.GetPageModules(int.Parse(siteid)))
|
||||
foreach (PageModule pagemodule in _pageModules.GetPageModules(int.Parse(siteid)))
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "View", pagemodule.Module.Permissions))
|
||||
if (_userPermissions.IsAuthorized(User, "View", pagemodule.Module.Permissions))
|
||||
{
|
||||
Models.Module module = new Models.Module();
|
||||
module.SiteId = pagemodule.Module.SiteId;
|
||||
|
@ -69,16 +69,16 @@ namespace Oqtane.Controllers
|
|||
[HttpGet("{id}")]
|
||||
public Models.Module Get(int id)
|
||||
{
|
||||
Models.Module module = Modules.GetModule(id);
|
||||
if (UserPermissions.IsAuthorized(User, "View", module.Permissions))
|
||||
Models.Module module = _modules.GetModule(id);
|
||||
if (_userPermissions.IsAuthorized(User, "View", module.Permissions))
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||
module.ModuleDefinition = moduledefinitions.Find(item => item.ModuleDefinitionName == module.ModuleDefinitionName);
|
||||
return module;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Module {Module}", module);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Module {Module}", module);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -89,14 +89,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Models.Module Post([FromBody] Models.Module Module)
|
||||
{
|
||||
if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Page", Module.PageId, "Edit"))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Page", Module.PageId, "Edit"))
|
||||
{
|
||||
Module = Modules.AddModule(Module);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", Module);
|
||||
Module = _modules.AddModule(Module);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", Module);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Module {Module}", Module);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Module {Module}", Module);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Module = null;
|
||||
}
|
||||
|
@ -108,14 +108,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Models.Module Put(int id, [FromBody] Models.Module Module)
|
||||
{
|
||||
if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Module", Module.ModuleId, "Edit"))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Module", Module.ModuleId, "Edit"))
|
||||
{
|
||||
Module = Modules.UpdateModule(Module);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", Module);
|
||||
Module = _modules.UpdateModule(Module);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", Module);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Module {Module}", Module);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Module {Module}", Module);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Module = null;
|
||||
}
|
||||
|
@ -127,14 +127,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "Module", id, "Edit"))
|
||||
if (_userPermissions.IsAuthorized(User, "Module", id, "Edit"))
|
||||
{
|
||||
Modules.DeleteModule(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Deleted {ModuleId}", id);
|
||||
_modules.DeleteModule(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Deleted {ModuleId}", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Module {ModuleId}", id);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Module {ModuleId}", id);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
@ -145,13 +145,13 @@ namespace Oqtane.Controllers
|
|||
public string Export(int moduleid)
|
||||
{
|
||||
string content = "";
|
||||
if (UserPermissions.IsAuthorized(User, "Module", moduleid, "Edit"))
|
||||
if (_userPermissions.IsAuthorized(User, "Module", moduleid, "Edit"))
|
||||
{
|
||||
content = Modules.ExportModule(moduleid);
|
||||
content = _modules.ExportModule(moduleid);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Other, "User Not Authorized To Export Module {ModuleId}", moduleid);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Other, "User Not Authorized To Export Module {ModuleId}", moduleid);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
return content;
|
||||
|
@ -163,13 +163,13 @@ namespace Oqtane.Controllers
|
|||
public bool Import(int moduleid, [FromBody] string Content)
|
||||
{
|
||||
bool success = false;
|
||||
if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Module", moduleid, "Edit"))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Module", moduleid, "Edit"))
|
||||
{
|
||||
success = Modules.ImportModule(moduleid, Content);
|
||||
success = _modules.ImportModule(moduleid, Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Other, "User Not Authorized To Import Module {ModuleId}", moduleid);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Other, "User Not Authorized To Import Module {ModuleId}", moduleid);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
return success;
|
||||
|
|
|
@ -16,19 +16,19 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class ModuleDefinitionController : Controller
|
||||
{
|
||||
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly IInstallationManager InstallationManager;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IModuleDefinitionRepository _moduleDefinitions;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly IInstallationManager _installationManager;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IUserPermissions UserPermissions, IInstallationManager InstallationManager, IWebHostEnvironment environment, ILogManager logger)
|
||||
{
|
||||
this.ModuleDefinitions = ModuleDefinitions;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.InstallationManager = InstallationManager;
|
||||
this.environment = environment;
|
||||
this.logger = logger;
|
||||
this._moduleDefinitions = ModuleDefinitions;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._installationManager = InstallationManager;
|
||||
this._environment = environment;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
|
@ -36,9 +36,9 @@ namespace Oqtane.Controllers
|
|||
public IEnumerable<ModuleDefinition> Get(string siteid)
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = new List<ModuleDefinition>();
|
||||
foreach(ModuleDefinition moduledefinition in ModuleDefinitions.GetModuleDefinitions(int.Parse(siteid)))
|
||||
foreach(ModuleDefinition moduledefinition in _moduleDefinitions.GetModuleDefinitions(int.Parse(siteid)))
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "Utilize", moduledefinition.Permissions))
|
||||
if (_userPermissions.IsAuthorized(User, "Utilize", moduledefinition.Permissions))
|
||||
{
|
||||
moduledefinitions.Add(moduledefinition);
|
||||
}
|
||||
|
@ -50,14 +50,14 @@ namespace Oqtane.Controllers
|
|||
[HttpGet("{id}")]
|
||||
public ModuleDefinition Get(int id, string siteid)
|
||||
{
|
||||
ModuleDefinition moduledefinition = ModuleDefinitions.GetModuleDefinition(id, int.Parse(siteid));
|
||||
if (UserPermissions.IsAuthorized(User, "Utilize", moduledefinition.Permissions))
|
||||
ModuleDefinition moduledefinition = _moduleDefinitions.GetModuleDefinition(id, int.Parse(siteid));
|
||||
if (_userPermissions.IsAuthorized(User, "Utilize", moduledefinition.Permissions))
|
||||
{
|
||||
return moduledefinition;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access ModuleDefinition {ModuleDefinition}", moduledefinition);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access ModuleDefinition {ModuleDefinition}", moduledefinition);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ModuleDefinitions.UpdateModuleDefinition(ModuleDefinition);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Definition Updated {ModuleDefinition}", ModuleDefinition);
|
||||
_moduleDefinitions.UpdateModuleDefinition(ModuleDefinition);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Definition Updated {ModuleDefinition}", ModuleDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void InstallModules()
|
||||
{
|
||||
InstallationManager.InstallPackages("Modules", true);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Modules Installed");
|
||||
_installationManager.InstallPackages("Modules", true);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Modules Installed");
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5?siteid=x
|
||||
|
@ -88,13 +88,13 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(int id, int siteid)
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(siteid).ToList();
|
||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(siteid).ToList();
|
||||
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionId == id).FirstOrDefault();
|
||||
if (moduledefinition != null)
|
||||
{
|
||||
string moduledefinitionname = moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(","));
|
||||
|
||||
string folder = Path.Combine(environment.WebRootPath, "Modules\\" + moduledefinitionname);
|
||||
string folder = Path.Combine(_environment.WebRootPath, "Modules\\" + moduledefinitionname);
|
||||
if (Directory.Exists(folder))
|
||||
{
|
||||
Directory.Delete(folder, true);
|
||||
|
@ -106,10 +106,10 @@ namespace Oqtane.Controllers
|
|||
System.IO.File.Delete(file);
|
||||
}
|
||||
|
||||
ModuleDefinitions.DeleteModuleDefinition(id, siteid);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Deleted {ModuleDefinitionId}", id);
|
||||
_moduleDefinitions.DeleteModuleDefinition(id, siteid);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Module Deleted {ModuleDefinitionId}", id);
|
||||
|
||||
InstallationManager.RestartApplication();
|
||||
_installationManager.RestartApplication();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,15 +13,15 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class NotificationController : Controller
|
||||
{
|
||||
private readonly INotificationRepository Notifications;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ILogManager logger;
|
||||
private readonly INotificationRepository _notifications;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public NotificationController(INotificationRepository Notifications, IUserPermissions UserPermissions, ILogManager logger)
|
||||
{
|
||||
this.Notifications = Notifications;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.logger = logger;
|
||||
this._notifications = Notifications;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x&type=y&userid=z
|
||||
|
@ -34,11 +34,11 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (direction == "to")
|
||||
{
|
||||
notifications = Notifications.GetNotifications(int.Parse(siteid), -1, int.Parse(userid));
|
||||
notifications = _notifications.GetNotifications(int.Parse(siteid), -1, int.Parse(userid));
|
||||
}
|
||||
else
|
||||
{
|
||||
notifications = Notifications.GetNotifications(int.Parse(siteid), int.Parse(userid), -1);
|
||||
notifications = _notifications.GetNotifications(int.Parse(siteid), int.Parse(userid), -1);
|
||||
}
|
||||
}
|
||||
return notifications;
|
||||
|
@ -49,7 +49,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Notification Get(int id)
|
||||
{
|
||||
Notification Notification = Notifications.GetNotification(id);
|
||||
Notification Notification = _notifications.GetNotification(id);
|
||||
if (!(IsAuthorized(Notification.FromUserId) || IsAuthorized(Notification.ToUserId)))
|
||||
{
|
||||
Notification = null;
|
||||
|
@ -64,8 +64,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (IsAuthorized(Notification.FromUserId))
|
||||
{
|
||||
Notification = Notifications.AddNotification(Notification);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Notification Added {Notification}", Notification);
|
||||
Notification = _notifications.AddNotification(Notification);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Notification Added {Notification}", Notification);
|
||||
}
|
||||
return Notification;
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (IsAuthorized(Notification.FromUserId))
|
||||
{
|
||||
Notification = Notifications.UpdateNotification(Notification);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Notification Updated {Folder}", Notification);
|
||||
Notification = _notifications.UpdateNotification(Notification);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Notification Updated {Folder}", Notification);
|
||||
}
|
||||
return Notification;
|
||||
}
|
||||
|
@ -88,11 +88,11 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Notification Notification = Notifications.GetNotification(id);
|
||||
Notification Notification = _notifications.GetNotification(id);
|
||||
if (IsAuthorized(Notification.FromUserId) || IsAuthorized(Notification.ToUserId))
|
||||
{
|
||||
Notifications.DeleteNotification(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Notification Deleted {NotificationId}", id);
|
||||
_notifications.DeleteNotification(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Notification Deleted {NotificationId}", id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace Oqtane.Controllers
|
|||
bool authorized = true;
|
||||
if (userid != null)
|
||||
{
|
||||
authorized = (UserPermissions.GetUser(User).UserId == userid);
|
||||
authorized = (_userPermissions.GetUser(User).UserId == userid);
|
||||
}
|
||||
return authorized;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class PackageController : Controller
|
||||
{
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
|
||||
public PackageController(IWebHostEnvironment environment)
|
||||
{
|
||||
this.environment = environment;
|
||||
this._environment = environment;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?tag=x
|
||||
|
@ -61,7 +61,7 @@ namespace Oqtane.Controllers
|
|||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
CancellationToken token;
|
||||
folder = Path.Combine(environment.WebRootPath, folder);
|
||||
folder = Path.Combine(_environment.WebRootPath, folder);
|
||||
var response = await httpClient.GetAsync("https://www.nuget.org/api/v2/package/" + packageid.ToLower() + "/" + version, token).ConfigureAwait(false);
|
||||
response.EnsureSuccessStatusCode();
|
||||
string filename = packageid + "." + version + ".nupkg";
|
||||
|
|
|
@ -13,19 +13,19 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class PageController : Controller
|
||||
{
|
||||
private readonly IPageRepository Pages;
|
||||
private readonly IModuleRepository Modules;
|
||||
private readonly IPageModuleRepository PageModules;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IPageRepository _pages;
|
||||
private readonly IModuleRepository _modules;
|
||||
private readonly IPageModuleRepository _pageModules;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public PageController(IPageRepository Pages, IModuleRepository Modules, IPageModuleRepository PageModules, IUserPermissions UserPermissions, ILogManager logger)
|
||||
{
|
||||
this.Pages = Pages;
|
||||
this.Modules = Modules;
|
||||
this.PageModules = PageModules;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.logger = logger;
|
||||
this._pages = Pages;
|
||||
this._modules = Modules;
|
||||
this._pageModules = PageModules;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
|
@ -33,9 +33,9 @@ namespace Oqtane.Controllers
|
|||
public IEnumerable<Page> Get(string siteid)
|
||||
{
|
||||
List<Page> pages = new List<Page>();
|
||||
foreach (Page page in Pages.GetPages(int.Parse(siteid)))
|
||||
foreach (Page page in _pages.GetPages(int.Parse(siteid)))
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "View", page.Permissions))
|
||||
if (_userPermissions.IsAuthorized(User, "View", page.Permissions))
|
||||
{
|
||||
pages.Add(page);
|
||||
}
|
||||
|
@ -50,19 +50,19 @@ namespace Oqtane.Controllers
|
|||
Page page;
|
||||
if (string.IsNullOrEmpty(userid))
|
||||
{
|
||||
page = Pages.GetPage(id);
|
||||
page = _pages.GetPage(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
page = Pages.GetPage(id, int.Parse(userid));
|
||||
page = _pages.GetPage(id, int.Parse(userid));
|
||||
}
|
||||
if (UserPermissions.IsAuthorized(User, "View", page.Permissions))
|
||||
if (_userPermissions.IsAuthorized(User, "View", page.Permissions))
|
||||
{
|
||||
return page;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Page {Page}", page);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Page {Page}", page);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -78,21 +78,21 @@ namespace Oqtane.Controllers
|
|||
string permissions;
|
||||
if (Page.ParentId != null)
|
||||
{
|
||||
permissions = Pages.GetPage(Page.ParentId.Value).Permissions;
|
||||
permissions = _pages.GetPage(Page.ParentId.Value).Permissions;
|
||||
}
|
||||
else
|
||||
{
|
||||
permissions = UserSecurity.SetPermissionStrings(new List<PermissionString> { new PermissionString { PermissionName = "Edit", Permissions = Constants.AdminRole } });
|
||||
}
|
||||
|
||||
if (UserPermissions.IsAuthorized(User, "Edit", permissions))
|
||||
if (_userPermissions.IsAuthorized(User, "Edit", permissions))
|
||||
{
|
||||
Page = Pages.AddPage(Page);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", Page);
|
||||
Page = _pages.AddPage(Page);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", Page);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Page {Page}", Page);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Page {Page}", Page);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Page = null;
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ namespace Oqtane.Controllers
|
|||
public Page Post(int id, string userid)
|
||||
{
|
||||
Page page = null;
|
||||
Page parent = Pages.GetPage(id);
|
||||
if (parent != null && parent.IsPersonalizable && UserPermissions.GetUser(User).UserId == int.Parse(userid))
|
||||
Page parent = _pages.GetPage(id);
|
||||
if (parent != null && parent.IsPersonalizable && _userPermissions.GetUser(User).UserId == int.Parse(userid))
|
||||
{
|
||||
page = new Page();
|
||||
page.SiteId = parent.SiteId;
|
||||
|
@ -126,10 +126,10 @@ namespace Oqtane.Controllers
|
|||
page.Permissions = UserSecurity.SetPermissionStrings(permissions);
|
||||
page.IsPersonalizable = false;
|
||||
page.UserId = int.Parse(userid);
|
||||
page = Pages.AddPage(page);
|
||||
page = _pages.AddPage(page);
|
||||
|
||||
// copy modules
|
||||
List<PageModule> pagemodules = PageModules.GetPageModules(page.SiteId).ToList();
|
||||
List<PageModule> pagemodules = _pageModules.GetPageModules(page.SiteId).ToList();
|
||||
foreach (PageModule pm in pagemodules.Where(item => item.PageId == parent.PageId && !item.IsDeleted))
|
||||
{
|
||||
Module module = new Module();
|
||||
|
@ -140,12 +140,12 @@ namespace Oqtane.Controllers
|
|||
permissions.Add(new PermissionString { PermissionName = "View", Permissions = "[" + userid + "]" });
|
||||
permissions.Add(new PermissionString { PermissionName = "Edit", Permissions = "[" + userid + "]" });
|
||||
module.Permissions = UserSecurity.SetPermissionStrings(permissions);
|
||||
module = Modules.AddModule(module);
|
||||
module = _modules.AddModule(module);
|
||||
|
||||
string content = Modules.ExportModule(pm.ModuleId);
|
||||
string content = _modules.ExportModule(pm.ModuleId);
|
||||
if (content != "")
|
||||
{
|
||||
Modules.ImportModule(module.ModuleId, content);
|
||||
_modules.ImportModule(module.ModuleId, content);
|
||||
}
|
||||
|
||||
PageModule pagemodule = new PageModule();
|
||||
|
@ -156,7 +156,7 @@ namespace Oqtane.Controllers
|
|||
pagemodule.Order = pm.Order;
|
||||
pagemodule.ContainerType = pm.ContainerType;
|
||||
|
||||
PageModules.AddPageModule(pagemodule);
|
||||
_pageModules.AddPageModule(pagemodule);
|
||||
}
|
||||
}
|
||||
return page;
|
||||
|
@ -167,14 +167,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Page Put(int id, [FromBody] Page Page)
|
||||
{
|
||||
if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Page", Page.PageId, "Edit"))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Page", Page.PageId, "Edit"))
|
||||
{
|
||||
Page = Pages.UpdatePage(Page);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Updated {Page}", Page);
|
||||
Page = _pages.UpdatePage(Page);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Updated {Page}", Page);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Page {Page}", Page);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Page {Page}", Page);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Page = null;
|
||||
}
|
||||
|
@ -186,24 +186,24 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Put(int siteid, int pageid, int? parentid)
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "Page", pageid, "Edit"))
|
||||
if (_userPermissions.IsAuthorized(User, "Page", pageid, "Edit"))
|
||||
{
|
||||
int order = 1;
|
||||
List<Page> pages = Pages.GetPages(siteid).ToList();
|
||||
List<Page> pages = _pages.GetPages(siteid).ToList();
|
||||
foreach (Page page in pages.Where(item => item.ParentId == parentid).OrderBy(item => item.Order))
|
||||
{
|
||||
if (page.Order != order)
|
||||
{
|
||||
page.Order = order;
|
||||
Pages.UpdatePage(page);
|
||||
_pages.UpdatePage(page);
|
||||
}
|
||||
order += 2;
|
||||
}
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Order Updated {SiteId} {PageId} {ParentId}", siteid, pageid, parentid);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Order Updated {SiteId} {PageId} {ParentId}", siteid, pageid, parentid);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Page Order {SiteId} {PageId} {ParentId}", siteid, pageid, parentid);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Page Order {SiteId} {PageId} {ParentId}", siteid, pageid, parentid);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
@ -213,14 +213,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "Page", id, "Edit"))
|
||||
if (_userPermissions.IsAuthorized(User, "Page", id, "Edit"))
|
||||
{
|
||||
Pages.DeletePage(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Page Deleted {PageId}", id);
|
||||
_pages.DeletePage(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Page Deleted {PageId}", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Page {PageId}", id);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Page {PageId}", id);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,31 +13,31 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class PageModuleController : Controller
|
||||
{
|
||||
private readonly IPageModuleRepository PageModules;
|
||||
private readonly IModuleRepository Modules;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IPageModuleRepository _pageModules;
|
||||
private readonly IModuleRepository _modules;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public PageModuleController(IPageModuleRepository PageModules, IModuleRepository Modules, IUserPermissions UserPermissions, ILogManager logger)
|
||||
{
|
||||
this.PageModules = PageModules;
|
||||
this.Modules = Modules;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.logger = logger;
|
||||
this._pageModules = PageModules;
|
||||
this._modules = Modules;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
public PageModule Get(int id)
|
||||
{
|
||||
PageModule pagemodule = PageModules.GetPageModule(id);
|
||||
if (UserPermissions.IsAuthorized(User, "View", pagemodule.Module.Permissions))
|
||||
PageModule pagemodule = _pageModules.GetPageModule(id);
|
||||
if (_userPermissions.IsAuthorized(User, "View", pagemodule.Module.Permissions))
|
||||
{
|
||||
return pagemodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access PageModule {PageModule}", pagemodule);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access PageModule {PageModule}", pagemodule);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ namespace Oqtane.Controllers
|
|||
[HttpGet("{pageid}/{moduleid}")]
|
||||
public PageModule Get(int pageid, int moduleid)
|
||||
{
|
||||
PageModule pagemodule = PageModules.GetPageModule(pageid, moduleid);
|
||||
if (UserPermissions.IsAuthorized(User, "View", pagemodule.Module.Permissions))
|
||||
PageModule pagemodule = _pageModules.GetPageModule(pageid, moduleid);
|
||||
if (_userPermissions.IsAuthorized(User, "View", pagemodule.Module.Permissions))
|
||||
{
|
||||
return pagemodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access PageModule {PageModule}", pagemodule);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access PageModule {PageModule}", pagemodule);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -65,14 +65,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public PageModule Post([FromBody] PageModule PageModule)
|
||||
{
|
||||
if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Page", PageModule.PageId, "Edit"))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Page", PageModule.PageId, "Edit"))
|
||||
{
|
||||
PageModule = PageModules.AddPageModule(PageModule);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Module Added {PageModule}", PageModule);
|
||||
PageModule = _pageModules.AddPageModule(PageModule);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Module Added {PageModule}", PageModule);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add PageModule {PageModule}", PageModule);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add PageModule {PageModule}", PageModule);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
PageModule = null;
|
||||
}
|
||||
|
@ -84,14 +84,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public PageModule Put(int id, [FromBody] PageModule PageModule)
|
||||
{
|
||||
if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Module", PageModule.ModuleId, "Edit"))
|
||||
if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Module", PageModule.ModuleId, "Edit"))
|
||||
{
|
||||
PageModule = PageModules.UpdatePageModule(PageModule);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Updated {PageModule}", PageModule);
|
||||
PageModule = _pageModules.UpdatePageModule(PageModule);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Updated {PageModule}", PageModule);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update PageModule {PageModule}", PageModule);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update PageModule {PageModule}", PageModule);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
PageModule = null;
|
||||
}
|
||||
|
@ -103,24 +103,24 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Put(int pageid, string pane)
|
||||
{
|
||||
if (UserPermissions.IsAuthorized(User, "Page", pageid, "Edit"))
|
||||
if (_userPermissions.IsAuthorized(User, "Page", pageid, "Edit"))
|
||||
{
|
||||
int order = 1;
|
||||
List<PageModule> pagemodules = PageModules.GetPageModules(pageid, pane).OrderBy(item => item.Order).ToList();
|
||||
List<PageModule> pagemodules = _pageModules.GetPageModules(pageid, pane).OrderBy(item => item.Order).ToList();
|
||||
foreach (PageModule pagemodule in pagemodules)
|
||||
{
|
||||
if (pagemodule.Order != order)
|
||||
{
|
||||
pagemodule.Order = order;
|
||||
PageModules.UpdatePageModule(pagemodule);
|
||||
_pageModules.UpdatePageModule(pagemodule);
|
||||
}
|
||||
order += 2;
|
||||
}
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Order Updated {PageId} {Pane}", pageid, pane);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Page Module Order Updated {PageId} {Pane}", pageid, pane);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Page Module Order {PageId} {Pane}", pageid, pane);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Page Module Order {PageId} {Pane}", pageid, pane);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
@ -130,15 +130,15 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
PageModule pagemodule = PageModules.GetPageModule(id);
|
||||
if (UserPermissions.IsAuthorized(User, "Page", pagemodule.PageId, "Edit"))
|
||||
PageModule pagemodule = _pageModules.GetPageModule(id);
|
||||
if (_userPermissions.IsAuthorized(User, "Page", pagemodule.PageId, "Edit"))
|
||||
{
|
||||
PageModules.DeletePageModule(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Page Module Deleted {PageModuleId}", id);
|
||||
_pageModules.DeletePageModule(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Page Module Deleted {PageModuleId}", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete PageModule {PageModuleId}", id);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete PageModule {PageModuleId}", id);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,27 +11,27 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class ProfileController : Controller
|
||||
{
|
||||
private readonly IProfileRepository Profiles;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IProfileRepository _profiles;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public ProfileController(IProfileRepository Profiles, ILogManager logger)
|
||||
{
|
||||
this.Profiles = Profiles;
|
||||
this.logger = logger;
|
||||
this._profiles = Profiles;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
[HttpGet]
|
||||
public IEnumerable<Profile> Get(string siteid)
|
||||
{
|
||||
return Profiles.GetProfiles(int.Parse(siteid));
|
||||
return _profiles.GetProfiles(int.Parse(siteid));
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
public Profile Get(int id)
|
||||
{
|
||||
return Profiles.GetProfile(id);
|
||||
return _profiles.GetProfile(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -41,8 +41,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Profile = Profiles.AddProfile(Profile);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Profile Added {Profile}", Profile);
|
||||
Profile = _profiles.AddProfile(Profile);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Profile Added {Profile}", Profile);
|
||||
}
|
||||
return Profile;
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Profile = Profiles.UpdateProfile(Profile);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Profile Updated {Profile}", Profile);
|
||||
Profile = _profiles.UpdateProfile(Profile);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Profile Updated {Profile}", Profile);
|
||||
}
|
||||
return Profile;
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Profiles.DeleteProfile(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Profile Deleted {ProfileId}", id);
|
||||
_profiles.DeleteProfile(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Profile Deleted {ProfileId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class RoleController : Controller
|
||||
{
|
||||
private readonly IRoleRepository Roles;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IRoleRepository _roles;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public RoleController(IRoleRepository Roles, ILogManager logger)
|
||||
{
|
||||
this.Roles = Roles;
|
||||
this.logger = logger;
|
||||
this._roles = Roles;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
|
@ -25,7 +25,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public IEnumerable<Role> Get(string siteid)
|
||||
{
|
||||
return Roles.GetRoles(int.Parse(siteid));
|
||||
return _roles.GetRoles(int.Parse(siteid));
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
|
@ -33,7 +33,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public Role Get(int id)
|
||||
{
|
||||
return Roles.GetRole(id);
|
||||
return _roles.GetRole(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -43,8 +43,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Role = Roles.AddRole(Role);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Role Added {Role}", Role);
|
||||
Role = _roles.AddRole(Role);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Role Added {Role}", Role);
|
||||
}
|
||||
return Role;
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Role = Roles.UpdateRole(Role);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Role Updated {Role}", Role);
|
||||
Role = _roles.UpdateRole(Role);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Role Updated {Role}", Role);
|
||||
}
|
||||
return Role;
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Roles.DeleteRole(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Role Deleted {RoleId}", id);
|
||||
_roles.DeleteRole(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Role Deleted {RoleId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,17 +13,17 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class SettingController : Controller
|
||||
{
|
||||
private readonly ISettingRepository Settings;
|
||||
private readonly IPageModuleRepository PageModules;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ILogManager logger;
|
||||
private readonly ISettingRepository _settings;
|
||||
private readonly IPageModuleRepository _pageModules;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public SettingController(ISettingRepository Settings, IPageModuleRepository PageModules, IUserPermissions UserPermissions, ILogManager logger)
|
||||
{
|
||||
this.Settings = Settings;
|
||||
this.PageModules = PageModules;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.logger = logger;
|
||||
this._settings = Settings;
|
||||
this._pageModules = PageModules;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
|
@ -33,11 +33,11 @@ namespace Oqtane.Controllers
|
|||
List<Setting> settings = new List<Setting>();
|
||||
if (IsAuthorized(entityname, entityid, "View"))
|
||||
{
|
||||
settings = Settings.GetSettings(entityname, entityid).ToList();
|
||||
settings = _settings.GetSettings(entityname, entityid).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Settings {EntityName} {EntityId}", entityname, entityid);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Settings {EntityName} {EntityId}", entityname, entityid);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
return settings;
|
||||
|
@ -47,14 +47,14 @@ namespace Oqtane.Controllers
|
|||
[HttpGet("{id}")]
|
||||
public Setting Get(int id)
|
||||
{
|
||||
Setting setting = Settings.GetSetting(id);
|
||||
Setting setting = _settings.GetSetting(id);
|
||||
if (IsAuthorized(setting.EntityName, setting.EntityId, "View"))
|
||||
{
|
||||
return setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Setting {Setting}", setting);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Setting {Setting}", setting);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
return null;
|
||||
}
|
||||
|
@ -66,12 +66,12 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid && IsAuthorized(Setting.EntityName, Setting.EntityId, "Edit"))
|
||||
{
|
||||
Setting = Settings.AddSetting(Setting);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Setting Added {Setting}", Setting);
|
||||
Setting = _settings.AddSetting(Setting);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Setting Added {Setting}", Setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Setting {Setting}", Setting);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Setting {Setting}", Setting);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Setting = null;
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid && IsAuthorized(Setting.EntityName, Setting.EntityId, "Edit"))
|
||||
{
|
||||
Setting = Settings.UpdateSetting(Setting);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Setting Updated {Setting}", Setting);
|
||||
Setting = _settings.UpdateSetting(Setting);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Setting Updated {Setting}", Setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Setting {Setting}", Setting);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Setting {Setting}", Setting);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
Setting = null;
|
||||
}
|
||||
|
@ -100,15 +100,15 @@ namespace Oqtane.Controllers
|
|||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Setting setting = Settings.GetSetting(id);
|
||||
Setting setting = _settings.GetSetting(id);
|
||||
if (IsAuthorized(setting.EntityName, setting.EntityId, "Edit"))
|
||||
{
|
||||
Settings.DeleteSetting(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Setting Deleted {Setting}", setting);
|
||||
_settings.DeleteSetting(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Setting Deleted {Setting}", setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Setting {Setting}", setting);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Setting {Setting}", setting);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ namespace Oqtane.Controllers
|
|||
if (EntityName == "PageModule")
|
||||
{
|
||||
EntityName = "Module";
|
||||
EntityId = PageModules.GetPageModule(EntityId).ModuleId;
|
||||
EntityId = _pageModules.GetPageModule(EntityId).ModuleId;
|
||||
}
|
||||
switch (EntityName)
|
||||
{
|
||||
|
@ -132,13 +132,13 @@ namespace Oqtane.Controllers
|
|||
case "Page":
|
||||
case "Module":
|
||||
case "Folder":
|
||||
authorized = UserPermissions.IsAuthorized(User, EntityName, EntityId, PermissionName);
|
||||
authorized = _userPermissions.IsAuthorized(User, EntityName, EntityId, PermissionName);
|
||||
break;
|
||||
case "User":
|
||||
authorized = true;
|
||||
if (PermissionName == "Edit")
|
||||
{
|
||||
authorized = User.IsInRole(Constants.AdminRole) || (UserPermissions.GetUser(User).UserId == EntityId);
|
||||
authorized = User.IsInRole(Constants.AdminRole) || (_userPermissions.GetUser(User).UserId == EntityId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -14,17 +14,17 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class SiteController : Controller
|
||||
{
|
||||
private readonly ISiteRepository Sites;
|
||||
private readonly ITenantResolver Tenants;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly ILogManager logger;
|
||||
private readonly ISiteRepository _sites;
|
||||
private readonly ITenantResolver _tenants;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public SiteController(ISiteRepository Sites, ITenantResolver Tenants, IWebHostEnvironment environment, ILogManager logger)
|
||||
{
|
||||
this.Sites = Sites;
|
||||
this.Tenants = Tenants;
|
||||
this.environment = environment;
|
||||
this.logger = logger;
|
||||
this._sites = Sites;
|
||||
this._tenants = Tenants;
|
||||
this._environment = environment;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
|
@ -32,14 +32,14 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public IEnumerable<Site> Get()
|
||||
{
|
||||
return Sites.GetSites();
|
||||
return _sites.GetSites();
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
public Site Get(int id)
|
||||
{
|
||||
return Sites.GetSite(id);
|
||||
return _sites.GetSite(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -49,11 +49,11 @@ namespace Oqtane.Controllers
|
|||
if (ModelState.IsValid)
|
||||
{
|
||||
bool authorized;
|
||||
if (!Sites.GetSites().Any())
|
||||
if (!_sites.GetSites().Any())
|
||||
{
|
||||
// provision initial site during installation
|
||||
authorized = true;
|
||||
Tenant tenant = Tenants.GetTenant();
|
||||
Tenant tenant = _tenants.GetTenant();
|
||||
Site.TenantId = tenant.TenantId;
|
||||
}
|
||||
else
|
||||
|
@ -62,8 +62,8 @@ 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;
|
||||
|
@ -76,8 +76,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Site = Sites.UpdateSite(Site);
|
||||
logger.Log(Site.SiteId, LogLevel.Information, this, LogFunction.Update, "Site Updated {Site}", Site);
|
||||
Site = _sites.UpdateSite(Site);
|
||||
_logger.Log(Site.SiteId, LogLevel.Information, this, LogFunction.Update, "Site Updated {Site}", Site);
|
||||
}
|
||||
return Site;
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Sites.DeleteSite(id);
|
||||
logger.Log(id, LogLevel.Information, this, LogFunction.Delete, "Site Deleted {SiteId}", id);
|
||||
_sites.DeleteSite(id);
|
||||
_logger.Log(id, LogLevel.Information, this, LogFunction.Delete, "Site Deleted {SiteId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class TenantController : Controller
|
||||
{
|
||||
private readonly ITenantRepository Tenants;
|
||||
private readonly ILogManager logger;
|
||||
private readonly ITenantRepository _tenants;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public TenantController(ITenantRepository Tenants, ILogManager logger)
|
||||
{
|
||||
this.Tenants = Tenants;
|
||||
this.logger = logger;
|
||||
this._tenants = Tenants;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
|
@ -25,7 +25,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public IEnumerable<Tenant> Get()
|
||||
{
|
||||
return Tenants.GetTenants();
|
||||
return _tenants.GetTenants();
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
|
@ -33,7 +33,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public Tenant Get(int id)
|
||||
{
|
||||
return Tenants.GetTenant(id);
|
||||
return _tenants.GetTenant(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -43,8 +43,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Tenant = Tenants.AddTenant(Tenant);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Tenant Added {TenantId}", Tenant.TenantId);
|
||||
Tenant = _tenants.AddTenant(Tenant);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Tenant Added {TenantId}", Tenant.TenantId);
|
||||
}
|
||||
return Tenant;
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Tenant = Tenants.UpdateTenant(Tenant);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Tenant Updated {TenantId}", Tenant.TenantId);
|
||||
Tenant = _tenants.UpdateTenant(Tenant);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Tenant Updated {TenantId}", Tenant.TenantId);
|
||||
}
|
||||
return Tenant;
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
Tenants.DeleteTenant(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Tenant Deleted {TenantId}", id);
|
||||
_tenants.DeleteTenant(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Tenant Deleted {TenantId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,17 +15,17 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class ThemeController : Controller
|
||||
{
|
||||
private readonly IThemeRepository Themes;
|
||||
private readonly IInstallationManager InstallationManager;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IThemeRepository _themes;
|
||||
private readonly IInstallationManager _installationManager;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public ThemeController(IThemeRepository Themes, IInstallationManager InstallationManager, IWebHostEnvironment environment, ILogManager logger)
|
||||
{
|
||||
this.Themes = Themes;
|
||||
this.InstallationManager = InstallationManager;
|
||||
this.environment = environment;
|
||||
this.logger = logger;
|
||||
this._themes = Themes;
|
||||
this._installationManager = InstallationManager;
|
||||
this._environment = environment;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
|
@ -33,15 +33,15 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public IEnumerable<Theme> Get()
|
||||
{
|
||||
return Themes.GetThemes();
|
||||
return _themes.GetThemes();
|
||||
}
|
||||
|
||||
[HttpGet("install")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void InstallThemes()
|
||||
{
|
||||
InstallationManager.InstallPackages("Themes", true);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Themes Installed");
|
||||
_installationManager.InstallPackages("Themes", true);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Themes Installed");
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/xxx
|
||||
|
@ -49,13 +49,13 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void Delete(string themename)
|
||||
{
|
||||
List<Theme> themes = Themes.GetThemes().ToList();
|
||||
List<Theme> themes = _themes.GetThemes().ToList();
|
||||
Theme theme = themes.Where(item => item.ThemeName == themename).FirstOrDefault();
|
||||
if (theme != null)
|
||||
{
|
||||
themename = theme.ThemeName.Substring(0, theme.ThemeName.IndexOf(","));
|
||||
|
||||
string folder = Path.Combine(environment.WebRootPath, "Themes\\" + themename);
|
||||
string folder = Path.Combine(_environment.WebRootPath, "Themes\\" + themename);
|
||||
if (Directory.Exists(folder))
|
||||
{
|
||||
Directory.Delete(folder, true);
|
||||
|
@ -66,9 +66,9 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
System.IO.File.Delete(file);
|
||||
}
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Deleted {ThemeName}", themename);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Theme Deleted {ThemeName}", themename);
|
||||
|
||||
InstallationManager.RestartApplication();
|
||||
_installationManager.RestartApplication();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,27 +19,27 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class UserController : Controller
|
||||
{
|
||||
private readonly IUserRepository Users;
|
||||
private readonly IRoleRepository Roles;
|
||||
private readonly IUserRoleRepository UserRoles;
|
||||
private readonly UserManager<IdentityUser> IdentityUserManager;
|
||||
private readonly SignInManager<IdentityUser> IdentitySignInManager;
|
||||
private readonly ITenantResolver Tenants;
|
||||
private readonly INotificationRepository Notifications;
|
||||
private readonly IFolderRepository Folders;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IUserRepository _users;
|
||||
private readonly IRoleRepository _roles;
|
||||
private readonly IUserRoleRepository _userRoles;
|
||||
private readonly UserManager<IdentityUser> _identityUserManager;
|
||||
private readonly SignInManager<IdentityUser> _identitySignInManager;
|
||||
private readonly ITenantResolver _tenants;
|
||||
private readonly INotificationRepository _notifications;
|
||||
private readonly IFolderRepository _folders;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public UserController(IUserRepository Users, IRoleRepository Roles, IUserRoleRepository UserRoles, UserManager<IdentityUser> IdentityUserManager, SignInManager<IdentityUser> IdentitySignInManager, ITenantResolver Tenants, INotificationRepository Notifications, IFolderRepository Folders, ILogManager logger)
|
||||
{
|
||||
this.Users = Users;
|
||||
this.Roles = Roles;
|
||||
this.UserRoles = UserRoles;
|
||||
this.IdentityUserManager = IdentityUserManager;
|
||||
this.IdentitySignInManager = IdentitySignInManager;
|
||||
this.Tenants = Tenants;
|
||||
this.Folders = Folders;
|
||||
this.Notifications = Notifications;
|
||||
this.logger = logger;
|
||||
this._users = Users;
|
||||
this._roles = Roles;
|
||||
this._userRoles = UserRoles;
|
||||
this._identityUserManager = IdentityUserManager;
|
||||
this._identitySignInManager = IdentitySignInManager;
|
||||
this._tenants = Tenants;
|
||||
this._folders = Folders;
|
||||
this._notifications = Notifications;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET api/<controller>/5?siteid=x
|
||||
|
@ -47,7 +47,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize]
|
||||
public User Get(int id, string siteid)
|
||||
{
|
||||
User user = Users.GetUser(id);
|
||||
User user = _users.GetUser(id);
|
||||
if (user != null)
|
||||
{
|
||||
user.SiteId = int.Parse(siteid);
|
||||
|
@ -60,7 +60,7 @@ namespace Oqtane.Controllers
|
|||
[HttpGet("name/{name}")]
|
||||
public User Get(string name, string siteid)
|
||||
{
|
||||
User user = Users.GetUser(name);
|
||||
User user = _users.GetUser(name);
|
||||
if (user != null)
|
||||
{
|
||||
user.SiteId = int.Parse(siteid);
|
||||
|
@ -84,19 +84,19 @@ namespace Oqtane.Controllers
|
|||
verified = false;
|
||||
}
|
||||
|
||||
IdentityUser identityuser = await IdentityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
if (identityuser == null)
|
||||
{
|
||||
identityuser = new IdentityUser();
|
||||
identityuser.UserName = User.Username;
|
||||
identityuser.Email = User.Email;
|
||||
identityuser.EmailConfirmed = verified;
|
||||
var result = await IdentityUserManager.CreateAsync(identityuser, User.Password);
|
||||
var result = await _identityUserManager.CreateAsync(identityuser, User.Password);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
User.LastLoginOn = null;
|
||||
User.LastIPAddress = "";
|
||||
user = Users.AddUser(User);
|
||||
user = _users.AddUser(User);
|
||||
if (!verified)
|
||||
{
|
||||
Notification notification = new Notification();
|
||||
|
@ -105,50 +105,50 @@ namespace Oqtane.Controllers
|
|||
notification.ToUserId = user.UserId;
|
||||
notification.ToEmail = "";
|
||||
notification.Subject = "User Account Verification";
|
||||
string token = await IdentityUserManager.GenerateEmailConfirmationTokenAsync(identityuser);
|
||||
string url = HttpContext.Request.Scheme + "://" + Tenants.GetAlias().Name + "/login?name=" + User.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
string token = await _identityUserManager.GenerateEmailConfirmationTokenAsync(identityuser);
|
||||
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/login?name=" + User.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
notification.Body = "Dear " + User.DisplayName + ",\n\nIn Order To Complete The Registration Of Your User Account Please Click The Link Displayed Below:\n\n" + url + "\n\nThank You!";
|
||||
notification.ParentId = null;
|
||||
notification.CreatedOn = DateTime.Now;
|
||||
notification.IsDelivered = false;
|
||||
notification.DeliveredOn = null;
|
||||
Notifications.AddNotification(notification);
|
||||
_notifications.AddNotification(notification);
|
||||
}
|
||||
|
||||
// assign to host role if this is the host user ( initial installation )
|
||||
if (User.Username == Constants.HostUser)
|
||||
{
|
||||
int hostroleid = Roles.GetRoles(User.SiteId, true).Where(item => item.Name == Constants.HostRole).FirstOrDefault().RoleId;
|
||||
int hostroleid = _roles.GetRoles(User.SiteId, true).Where(item => item.Name == Constants.HostRole).FirstOrDefault().RoleId;
|
||||
UserRole userrole = new UserRole();
|
||||
userrole.UserId = user.UserId;
|
||||
userrole.RoleId = hostroleid;
|
||||
userrole.EffectiveDate = null;
|
||||
userrole.ExpiryDate = null;
|
||||
UserRoles.AddUserRole(userrole);
|
||||
_userRoles.AddUserRole(userrole);
|
||||
}
|
||||
|
||||
// add folder for user
|
||||
Folder folder = Folders.GetFolder(User.SiteId, "Users\\");
|
||||
Folder folder = _folders.GetFolder(User.SiteId, "Users\\");
|
||||
if (folder != null)
|
||||
{
|
||||
Folders.AddFolder(new Folder { SiteId = folder.SiteId, ParentId = folder.FolderId, Name = "My Folder", Path = folder.Path + user.UserId.ToString() + "\\", Order = 1, IsSystem = true,
|
||||
_folders.AddFolder(new Folder { SiteId = folder.SiteId, ParentId = folder.FolderId, Name = "My Folder", Path = folder.Path + user.UserId.ToString() + "\\", Order = 1, IsSystem = true,
|
||||
Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"[" + user.UserId.ToString() + "]\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"[" + user.UserId.ToString() + "]\"}]" });
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await IdentitySignInManager.CheckPasswordSignInAsync(identityuser, User.Password, false);
|
||||
var result = await _identitySignInManager.CheckPasswordSignInAsync(identityuser, User.Password, false);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
user = Users.GetUser(User.Username);
|
||||
user = _users.GetUser(User.Username);
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null && User.Username != Constants.HostUser)
|
||||
{
|
||||
// add auto assigned roles to user for site
|
||||
List<Role> roles = Roles.GetRoles(User.SiteId).Where(item => item.IsAutoAssigned == true).ToList();
|
||||
List<Role> roles = _roles.GetRoles(User.SiteId).Where(item => item.IsAutoAssigned == true).ToList();
|
||||
foreach (Role role in roles)
|
||||
{
|
||||
UserRole userrole = new UserRole();
|
||||
|
@ -156,11 +156,11 @@ namespace Oqtane.Controllers
|
|||
userrole.RoleId = role.RoleId;
|
||||
userrole.EffectiveDate = null;
|
||||
userrole.ExpiryDate = null;
|
||||
UserRoles.AddUserRole(userrole);
|
||||
_userRoles.AddUserRole(userrole);
|
||||
}
|
||||
}
|
||||
user.Password = ""; // remove sensitive information
|
||||
logger.Log(User.SiteId, LogLevel.Information, this, LogFunction.Create, "User Added {User}", user);
|
||||
_logger.Log(User.SiteId, LogLevel.Information, this, LogFunction.Create, "User Added {User}", user);
|
||||
}
|
||||
|
||||
return user;
|
||||
|
@ -177,20 +177,20 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (User.Password != "")
|
||||
{
|
||||
IdentityUser identityuser = await IdentityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
identityuser.PasswordHash = IdentityUserManager.PasswordHasher.HashPassword(identityuser, User.Password);
|
||||
await IdentityUserManager.UpdateAsync(identityuser);
|
||||
identityuser.PasswordHash = _identityUserManager.PasswordHasher.HashPassword(identityuser, User.Password);
|
||||
await _identityUserManager.UpdateAsync(identityuser);
|
||||
}
|
||||
}
|
||||
User = Users.UpdateUser(User);
|
||||
User = _users.UpdateUser(User);
|
||||
User.Password = ""; // remove sensitive information
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "User Updated {User}", User);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "User Updated {User}", User);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update User {User}", User);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update User {User}", User);
|
||||
HttpContext.Response.StatusCode = 401;
|
||||
User = null;
|
||||
}
|
||||
|
@ -203,16 +203,16 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public async Task Delete(int id)
|
||||
{
|
||||
IdentityUser identityuser = await IdentityUserManager.FindByNameAsync(Users.GetUser(id).Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(_users.GetUser(id).Username);
|
||||
|
||||
if (identityuser != null)
|
||||
{
|
||||
var result = await IdentityUserManager.DeleteAsync(identityuser);
|
||||
var result = await _identityUserManager.DeleteAsync(identityuser);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
Users.DeleteUser(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Deleted {UserId}", id);
|
||||
_users.DeleteUser(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Deleted {UserId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,13 +225,13 @@ namespace Oqtane.Controllers
|
|||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityUser identityuser = await IdentityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
var result = await IdentitySignInManager.CheckPasswordSignInAsync(identityuser, User.Password, false);
|
||||
var result = await _identitySignInManager.CheckPasswordSignInAsync(identityuser, User.Password, false);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
user = Users.GetUser(identityuser.UserName);
|
||||
user = _users.GetUser(identityuser.UserName);
|
||||
if (user != null)
|
||||
{
|
||||
if (identityuser.EmailConfirmed)
|
||||
|
@ -239,22 +239,22 @@ namespace Oqtane.Controllers
|
|||
user.IsAuthenticated = true;
|
||||
user.LastLoginOn = DateTime.Now;
|
||||
user.LastIPAddress = HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
Users.UpdateUser(user);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Security, "User Login Successful {Username}", User.Username);
|
||||
_users.UpdateUser(user);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Login Successful {Username}", User.Username);
|
||||
if (SetCookie)
|
||||
{
|
||||
await IdentitySignInManager.SignInAsync(identityuser, IsPersistent);
|
||||
await _identitySignInManager.SignInAsync(identityuser, IsPersistent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Security, "User Not Verified {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Not Verified {Username}", User.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Security, "User Login Failed {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "User Login Failed {Username}", User.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ namespace Oqtane.Controllers
|
|||
public async Task Logout([FromBody] User User)
|
||||
{
|
||||
await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Security, "User Logout {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Logout {Username}", User.Username);
|
||||
}
|
||||
|
||||
// POST api/<controller>/verify
|
||||
|
@ -277,23 +277,23 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityUser identityuser = await IdentityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
var result = await IdentityUserManager.ConfirmEmailAsync(identityuser, token);
|
||||
var result = await _identityUserManager.ConfirmEmailAsync(identityuser, token);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Security, "Email Verified For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Email Verified For {Username}", User.Username);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Security, "Email Verification Failed For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Email Verification Failed For {Username}", User.Username);
|
||||
User = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Security, "Email Verification Failed For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Email Verification Failed For {Username}", User.Username);
|
||||
User = null;
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityUser identityuser = await IdentityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
if (identityuser != null)
|
||||
{
|
||||
Notification notification = new Notification();
|
||||
|
@ -315,19 +315,19 @@ namespace Oqtane.Controllers
|
|||
notification.ToUserId = User.UserId;
|
||||
notification.ToEmail = "";
|
||||
notification.Subject = "User Password Reset";
|
||||
string token = await IdentityUserManager.GeneratePasswordResetTokenAsync(identityuser);
|
||||
string url = HttpContext.Request.Scheme + "://" + Tenants.GetAlias().Name + "/reset?name=" + User.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
string token = await _identityUserManager.GeneratePasswordResetTokenAsync(identityuser);
|
||||
string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/reset?name=" + User.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||
notification.Body = "Dear " + User.DisplayName + ",\n\nPlease Click The Link Displayed Below To Reset Your Password:\n\n" + url + "\n\nThank You!";
|
||||
notification.ParentId = null;
|
||||
notification.CreatedOn = DateTime.Now;
|
||||
notification.IsDelivered = false;
|
||||
notification.DeliveredOn = null;
|
||||
Notifications.AddNotification(notification);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset Notification Sent For {Username}", User.Username);
|
||||
_notifications.AddNotification(notification);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset Notification Sent For {Username}", User.Username);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Notification Failed For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Notification Failed For {Username}", User.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -338,24 +338,24 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
IdentityUser identityuser = await IdentityUserManager.FindByNameAsync(User.Username);
|
||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(User.Username);
|
||||
if (identityuser != null && !string.IsNullOrEmpty(token))
|
||||
{
|
||||
var result = await IdentityUserManager.ResetPasswordAsync(identityuser, token, User.Password);
|
||||
var result = await _identityUserManager.ResetPasswordAsync(identityuser, token, User.Password);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset For {Username}", User.Username);
|
||||
User.Password = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Failed For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Failed For {Username}", User.Username);
|
||||
User = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Failed For {Username}", User.Username);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Password Reset Failed For {Username}", User.Username);
|
||||
User = null;
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ namespace Oqtane.Controllers
|
|||
private string GetUserRoles(int UserId, int SiteId)
|
||||
{
|
||||
string roles = "";
|
||||
List<UserRole> userroles = UserRoles.GetUserRoles(UserId, SiteId).ToList();
|
||||
List<UserRole> userroles = _userRoles.GetUserRoles(UserId, SiteId).ToList();
|
||||
foreach (UserRole userrole in userroles)
|
||||
{
|
||||
roles += userrole.Role.Name + ";";
|
||||
|
|
|
@ -11,13 +11,13 @@ namespace Oqtane.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class UserRoleController : Controller
|
||||
{
|
||||
private readonly IUserRoleRepository UserRoles;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IUserRoleRepository _userRoles;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public UserRoleController(IUserRoleRepository UserRoles, ILogManager logger)
|
||||
{
|
||||
this.UserRoles = UserRoles;
|
||||
this.logger = logger;
|
||||
this._userRoles = UserRoles;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?userid=x
|
||||
|
@ -25,7 +25,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize]
|
||||
public IEnumerable<UserRole> Get(string siteid)
|
||||
{
|
||||
return UserRoles.GetUserRoles(int.Parse(siteid));
|
||||
return _userRoles.GetUserRoles(int.Parse(siteid));
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
|
@ -33,7 +33,7 @@ namespace Oqtane.Controllers
|
|||
[Authorize]
|
||||
public UserRole Get(int id)
|
||||
{
|
||||
return UserRoles.GetUserRole(id);
|
||||
return _userRoles.GetUserRole(id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
|
@ -43,8 +43,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
UserRole = UserRoles.AddUserRole(UserRole);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "User Role Added {UserRole}", UserRole);
|
||||
UserRole = _userRoles.AddUserRole(UserRole);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "User Role Added {UserRole}", UserRole);
|
||||
}
|
||||
return UserRole;
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
UserRole = UserRoles.UpdateUserRole(UserRole);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "User Role Updated {UserRole}", UserRole);
|
||||
UserRole = _userRoles.UpdateUserRole(UserRole);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "User Role Updated {UserRole}", UserRole);
|
||||
}
|
||||
return UserRole;
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ namespace Oqtane.Controllers
|
|||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
UserRoles.DeleteUserRole(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Role Deleted {UserRoleId}", id);
|
||||
_userRoles.DeleteUserRole(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Role Deleted {UserRoleId}", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ namespace Oqtane.Infrastructure
|
|||
{
|
||||
public class InstallationManager : IInstallationManager
|
||||
{
|
||||
private readonly IHostApplicationLifetime HostApplicationLifetime;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly IHostApplicationLifetime _hostApplicationLifetime;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
|
||||
public InstallationManager(IHostApplicationLifetime HostApplicationLifetime, IWebHostEnvironment environment)
|
||||
{
|
||||
this.HostApplicationLifetime = HostApplicationLifetime;
|
||||
this.environment = environment;
|
||||
this._hostApplicationLifetime = HostApplicationLifetime;
|
||||
this._environment = environment;
|
||||
}
|
||||
|
||||
public void InstallPackages(string Folders, bool Restart)
|
||||
|
@ -28,7 +28,7 @@ namespace Oqtane.Infrastructure
|
|||
|
||||
foreach (string Folder in Folders.Split(','))
|
||||
{
|
||||
string folder = Path.Combine(environment.WebRootPath, Folder);
|
||||
string folder = Path.Combine(_environment.WebRootPath, Folder);
|
||||
|
||||
// create folder if it does not exist
|
||||
if (!Directory.Exists(folder))
|
||||
|
@ -113,7 +113,7 @@ namespace Oqtane.Infrastructure
|
|||
|
||||
public void UpgradeFramework()
|
||||
{
|
||||
string folder = Path.Combine(environment.WebRootPath, "Framework");
|
||||
string folder = Path.Combine(_environment.WebRootPath, "Framework");
|
||||
if (Directory.Exists(folder))
|
||||
{
|
||||
// get package with highest version and clean up any others
|
||||
|
@ -189,7 +189,7 @@ namespace Oqtane.Infrastructure
|
|||
|
||||
public void RestartApplication()
|
||||
{
|
||||
HostApplicationLifetime.StopApplication();
|
||||
_hostApplicationLifetime.StopApplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@ namespace Oqtane.Infrastructure
|
|||
public abstract class HostedServiceBase : IHostedService, IDisposable
|
||||
{
|
||||
private Task ExecutingTask;
|
||||
private readonly CancellationTokenSource CancellationTokenSource = new CancellationTokenSource();
|
||||
private readonly IServiceScopeFactory ServiceScopeFactory;
|
||||
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
|
||||
public HostedServiceBase(IServiceScopeFactory ServiceScopeFactory)
|
||||
{
|
||||
this.ServiceScopeFactory = ServiceScopeFactory;
|
||||
this._serviceScopeFactory = ServiceScopeFactory;
|
||||
}
|
||||
|
||||
// abstract method must be overridden
|
||||
|
@ -31,7 +31,7 @@ namespace Oqtane.Infrastructure
|
|||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
// get name of job
|
||||
string JobType = Utilities.GetFullTypeName(this.GetType().AssemblyQualifiedName);
|
||||
|
@ -144,7 +144,7 @@ namespace Oqtane.Infrastructure
|
|||
try
|
||||
{
|
||||
// set IsExecuting to false in case this job was forcefully terminated previously
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
string JobType = Utilities.GetFullTypeName(this.GetType().AssemblyQualifiedName);
|
||||
IJobRepository Jobs = scope.ServiceProvider.GetRequiredService<IJobRepository>();
|
||||
|
@ -162,7 +162,7 @@ namespace Oqtane.Infrastructure
|
|||
// can occur during the initial installation as there is no DBContext
|
||||
}
|
||||
|
||||
ExecutingTask = ExecuteAsync(CancellationTokenSource.Token);
|
||||
ExecutingTask = ExecuteAsync(_cancellationTokenSource.Token);
|
||||
|
||||
if (ExecutingTask.IsCompleted)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ namespace Oqtane.Infrastructure
|
|||
|
||||
try
|
||||
{
|
||||
CancellationTokenSource.Cancel();
|
||||
_cancellationTokenSource.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ namespace Oqtane.Infrastructure
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
CancellationTokenSource.Cancel();
|
||||
_cancellationTokenSource.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,19 +12,19 @@ namespace Oqtane.Infrastructure
|
|||
{
|
||||
public class LogManager : ILogManager
|
||||
{
|
||||
private readonly ILogRepository Logs;
|
||||
private readonly ITenantResolver TenantResolver;
|
||||
private readonly IConfigurationRoot Config;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly IHttpContextAccessor Accessor;
|
||||
private readonly ILogRepository _logs;
|
||||
private readonly ITenantResolver _tenantResolver;
|
||||
private readonly IConfigurationRoot _config;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
|
||||
public LogManager(ILogRepository Logs, ITenantResolver TenantResolver, IConfigurationRoot Config, IUserPermissions UserPermissions, IHttpContextAccessor Accessor)
|
||||
{
|
||||
this.Logs = Logs;
|
||||
this.TenantResolver = TenantResolver;
|
||||
this.Config = Config;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.Accessor = Accessor;
|
||||
this._logs = Logs;
|
||||
this._tenantResolver = TenantResolver;
|
||||
this._config = Config;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._accessor = Accessor;
|
||||
}
|
||||
|
||||
public void Log(LogLevel Level, object Class, LogFunction Function, string Message, params object[] Args)
|
||||
|
@ -48,7 +48,7 @@ namespace Oqtane.Infrastructure
|
|||
if (SiteId == -1)
|
||||
{
|
||||
log.SiteId = null;
|
||||
Alias alias = TenantResolver.GetAlias();
|
||||
Alias alias = _tenantResolver.GetAlias();
|
||||
if (alias != null)
|
||||
{
|
||||
log.SiteId = alias.SiteId;
|
||||
|
@ -61,12 +61,12 @@ namespace Oqtane.Infrastructure
|
|||
log.PageId = null;
|
||||
log.ModuleId = null;
|
||||
log.UserId = null;
|
||||
User user = UserPermissions.GetUser();
|
||||
User user = _userPermissions.GetUser();
|
||||
if (user != null)
|
||||
{
|
||||
log.UserId = user.UserId;
|
||||
}
|
||||
HttpRequest request = Accessor.HttpContext.Request;
|
||||
HttpRequest request = _accessor.HttpContext.Request;
|
||||
if (request != null)
|
||||
{
|
||||
log.Url = request.Scheme.ToString() + "://" + request.Host.ToString() + request.Path.ToString() + request.QueryString.ToString();
|
||||
|
@ -105,10 +105,10 @@ namespace Oqtane.Infrastructure
|
|||
public void Log(Log Log)
|
||||
{
|
||||
LogLevel minlevel = LogLevel.Information;
|
||||
var section = Config.GetSection("Logging:LogLevel:Default");
|
||||
var section = _config.GetSection("Logging:LogLevel:Default");
|
||||
if (section.Exists())
|
||||
{
|
||||
minlevel = Enum.Parse<LogLevel>(Config.GetSection("Logging:LogLevel:Default").ToString());
|
||||
minlevel = Enum.Parse<LogLevel>(_config.GetSection("Logging:LogLevel:Default").ToString());
|
||||
}
|
||||
|
||||
if (Enum.Parse<LogLevel>(Log.Level) >= minlevel)
|
||||
|
@ -119,7 +119,7 @@ namespace Oqtane.Infrastructure
|
|||
Log = ProcessStructuredLog(Log);
|
||||
try
|
||||
{
|
||||
Logs.AddLog(Log);
|
||||
_logs.AddLog(Log);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -12,17 +12,17 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
|||
[Route("{site}/api/[controller]")]
|
||||
public class HtmlTextController : Controller
|
||||
{
|
||||
private readonly IHtmlTextRepository htmltext;
|
||||
private readonly ILogManager logger;
|
||||
private int EntityId = -1; // passed as a querystring parameter for authorization and used for validation
|
||||
private readonly IHtmlTextRepository _htmlText;
|
||||
private readonly ILogManager _logger;
|
||||
private int _entityId = -1; // passed as a querystring parameter for authorization and used for validation
|
||||
|
||||
public HtmlTextController(IHtmlTextRepository HtmlText, ILogManager logger, IHttpContextAccessor HttpContextAccessor)
|
||||
{
|
||||
htmltext = HtmlText;
|
||||
this.logger = logger;
|
||||
_htmlText = HtmlText;
|
||||
this._logger = logger;
|
||||
if (HttpContextAccessor.HttpContext.Request.Query.ContainsKey("entityid"))
|
||||
{
|
||||
EntityId = int.Parse(HttpContextAccessor.HttpContext.Request.Query["entityid"]);
|
||||
_entityId = int.Parse(HttpContextAccessor.HttpContext.Request.Query["entityid"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,15 +34,15 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
|||
try
|
||||
{
|
||||
HtmlTextInfo HtmlText = null;
|
||||
if (EntityId == id)
|
||||
if (_entityId == id)
|
||||
{
|
||||
HtmlText = htmltext.GetHtmlText(id);
|
||||
HtmlText = _htmlText.GetHtmlText(id);
|
||||
}
|
||||
return HtmlText;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Read, ex, "Get Error {Error}", ex.Message);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, ex, "Get Error {Error}", ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -54,16 +54,16 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
if (ModelState.IsValid && HtmlText.ModuleId == EntityId)
|
||||
if (ModelState.IsValid && HtmlText.ModuleId == _entityId)
|
||||
{
|
||||
HtmlText = htmltext.AddHtmlText(HtmlText);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Create, "Html/Text Added {HtmlText}", HtmlText);
|
||||
HtmlText = _htmlText.AddHtmlText(HtmlText);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Html/Text Added {HtmlText}", HtmlText);
|
||||
}
|
||||
return HtmlText;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Create, ex, "Post Error {Error}", ex.Message);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Create, ex, "Post Error {Error}", ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -75,16 +75,16 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
if (ModelState.IsValid && HtmlText.ModuleId == EntityId)
|
||||
if (ModelState.IsValid && HtmlText.ModuleId == _entityId)
|
||||
{
|
||||
HtmlText = htmltext.UpdateHtmlText(HtmlText);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Update, "Html/Text Updated {HtmlText}", HtmlText);
|
||||
HtmlText = _htmlText.UpdateHtmlText(HtmlText);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Html/Text Updated {HtmlText}", HtmlText);
|
||||
}
|
||||
return HtmlText;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Update, ex, "Put Error {Error}", ex.Message);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Update, ex, "Put Error {Error}", ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -96,15 +96,15 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
if (id == EntityId)
|
||||
if (id == _entityId)
|
||||
{
|
||||
htmltext.DeleteHtmlText(id);
|
||||
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Html/Text Deleted {HtmlTextId}", id);
|
||||
_htmlText.DeleteHtmlText(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Html/Text Deleted {HtmlTextId}", id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Delete, ex, "Delete Error {Error}", ex.Message);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, ex, "Delete Error {Error}", ex.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,17 +7,17 @@ namespace Oqtane.Modules.HtmlText.Manager
|
|||
{
|
||||
public class HtmlTextManager : IPortable
|
||||
{
|
||||
private IHtmlTextRepository htmltexts;
|
||||
private IHtmlTextRepository _htmlTexts;
|
||||
|
||||
public HtmlTextManager(IHtmlTextRepository htmltexts)
|
||||
{
|
||||
this.htmltexts = htmltexts;
|
||||
this._htmlTexts = htmltexts;
|
||||
}
|
||||
|
||||
public string ExportModule(Module Module)
|
||||
{
|
||||
string content = "";
|
||||
HtmlTextInfo htmltext = htmltexts.GetHtmlText(Module.ModuleId);
|
||||
HtmlTextInfo htmltext = _htmlTexts.GetHtmlText(Module.ModuleId);
|
||||
if (htmltext != null)
|
||||
{
|
||||
content = WebUtility.HtmlEncode(htmltext.Content);
|
||||
|
@ -28,18 +28,18 @@ namespace Oqtane.Modules.HtmlText.Manager
|
|||
public void ImportModule(Module Module, string Content, string Version)
|
||||
{
|
||||
Content = WebUtility.HtmlDecode(Content);
|
||||
HtmlTextInfo htmltext = htmltexts.GetHtmlText(Module.ModuleId);
|
||||
HtmlTextInfo htmltext = _htmlTexts.GetHtmlText(Module.ModuleId);
|
||||
if (htmltext != null)
|
||||
{
|
||||
htmltext.Content = Content;
|
||||
htmltexts.UpdateHtmlText(htmltext);
|
||||
_htmlTexts.UpdateHtmlText(htmltext);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = new HtmlTextInfo();
|
||||
htmltext.ModuleId = Module.ModuleId;
|
||||
htmltext.Content = Content;
|
||||
htmltexts.AddHtmlText(htmltext);
|
||||
_htmlTexts.AddHtmlText(htmltext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,18 +6,18 @@ namespace Oqtane.Modules.HtmlText.Repository
|
|||
{
|
||||
public class HtmlTextRepository : IHtmlTextRepository, IService
|
||||
{
|
||||
private readonly HtmlTextContext db;
|
||||
private readonly HtmlTextContext _db;
|
||||
|
||||
public HtmlTextRepository(HtmlTextContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public HtmlTextInfo GetHtmlText(int ModuleId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
|
||||
return _db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -30,8 +30,8 @@ namespace Oqtane.Modules.HtmlText.Repository
|
|||
{
|
||||
try
|
||||
{
|
||||
db.HtmlText.Add(HtmlText);
|
||||
db.SaveChanges();
|
||||
_db.HtmlText.Add(HtmlText);
|
||||
_db.SaveChanges();
|
||||
return HtmlText;
|
||||
}
|
||||
catch
|
||||
|
@ -44,8 +44,8 @@ namespace Oqtane.Modules.HtmlText.Repository
|
|||
{
|
||||
try
|
||||
{
|
||||
db.Entry(HtmlText).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(HtmlText).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return HtmlText;
|
||||
}
|
||||
catch
|
||||
|
@ -58,9 +58,9 @@ namespace Oqtane.Modules.HtmlText.Repository
|
|||
{
|
||||
try
|
||||
{
|
||||
HtmlTextInfo HtmlText = db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
|
||||
db.HtmlText.Remove(HtmlText);
|
||||
db.SaveChanges();
|
||||
HtmlTextInfo HtmlText = _db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
|
||||
_db.HtmlText.Remove(HtmlText);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -9,12 +9,12 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class AliasRepository : IAliasRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
private MasterDBContext _db;
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
public AliasRepository(MasterDBContext context, IMemoryCache cache)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
|
@ -23,37 +23,37 @@ namespace Oqtane.Repository
|
|||
return _cache.GetOrCreate("aliases", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
||||
return db.Alias.ToList();
|
||||
return _db.Alias.ToList();
|
||||
});
|
||||
}
|
||||
|
||||
public Alias AddAlias(Alias Alias)
|
||||
{
|
||||
db.Alias.Add(Alias);
|
||||
db.SaveChanges();
|
||||
_db.Alias.Add(Alias);
|
||||
_db.SaveChanges();
|
||||
_cache.Remove("aliases");
|
||||
return Alias;
|
||||
}
|
||||
|
||||
public Alias UpdateAlias(Alias Alias)
|
||||
{
|
||||
db.Entry(Alias).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Alias).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
_cache.Remove("aliases");
|
||||
return Alias;
|
||||
}
|
||||
|
||||
public Alias GetAlias(int AliasId)
|
||||
{
|
||||
return db.Alias.Find(AliasId);
|
||||
return _db.Alias.Find(AliasId);
|
||||
}
|
||||
|
||||
public void DeleteAlias(int AliasId)
|
||||
{
|
||||
Alias alias = db.Alias.Find(AliasId);
|
||||
db.Alias.Remove(alias);
|
||||
Alias alias = _db.Alias.Find(AliasId);
|
||||
_db.Alias.Remove(alias);
|
||||
_cache.Remove("aliases");
|
||||
db.SaveChanges();
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,18 +10,18 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class DBContextBase : IdentityUserContext<IdentityUser>
|
||||
{
|
||||
private Tenant tenant;
|
||||
private IHttpContextAccessor accessor;
|
||||
private Tenant _tenant;
|
||||
private IHttpContextAccessor _accessor;
|
||||
|
||||
public DBContextBase(ITenantResolver TenantResolver, IHttpContextAccessor accessor)
|
||||
{
|
||||
tenant = TenantResolver.GetTenant();
|
||||
this.accessor = accessor;
|
||||
_tenant = TenantResolver.GetTenant();
|
||||
this._accessor = accessor;
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(tenant.DBConnectionString
|
||||
optionsBuilder.UseSqlServer(_tenant.DBConnectionString
|
||||
.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory").ToString())
|
||||
);
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
@ -31,9 +31,9 @@ namespace Oqtane.Repository
|
|||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
if (tenant.DBSchema != "")
|
||||
if (_tenant.DBSchema != "")
|
||||
{
|
||||
modelBuilder.HasDefaultSchema(tenant.DBSchema);
|
||||
modelBuilder.HasDefaultSchema(_tenant.DBSchema);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,9 @@ namespace Oqtane.Repository
|
|||
ChangeTracker.DetectChanges();
|
||||
|
||||
string username = "";
|
||||
if (accessor.HttpContext != null && accessor.HttpContext.User.Identity.Name != null)
|
||||
if (_accessor.HttpContext != null && _accessor.HttpContext.User.Identity.Name != null)
|
||||
{
|
||||
username = accessor.HttpContext.User.Identity.Name;
|
||||
username = _accessor.HttpContext.User.Identity.Name;
|
||||
}
|
||||
DateTime date = DateTime.UtcNow;
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class MasterDBContext : DbContext
|
||||
{
|
||||
private IHttpContextAccessor accessor;
|
||||
private IHttpContextAccessor _accessor;
|
||||
|
||||
public MasterDBContext(DbContextOptions<MasterDBContext> options, IHttpContextAccessor accessor) : base(options)
|
||||
{
|
||||
this.accessor = accessor;
|
||||
this._accessor = accessor;
|
||||
}
|
||||
|
||||
public virtual DbSet<Alias> Alias { get; set; }
|
||||
|
@ -26,9 +26,9 @@ namespace Oqtane.Repository
|
|||
ChangeTracker.DetectChanges();
|
||||
|
||||
string username = "";
|
||||
if (accessor.HttpContext != null && accessor.HttpContext.User.Identity.Name != null)
|
||||
if (_accessor.HttpContext != null && _accessor.HttpContext.User.Identity.Name != null)
|
||||
{
|
||||
username = accessor.HttpContext.User.Identity.Name;
|
||||
username = _accessor.HttpContext.User.Identity.Name;
|
||||
}
|
||||
DateTime date = DateTime.Now;
|
||||
|
||||
|
|
|
@ -7,56 +7,56 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class FileRepository : IFileRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private readonly IPermissionRepository Permissions;
|
||||
private TenantDBContext _db;
|
||||
private readonly IPermissionRepository _permissions;
|
||||
|
||||
public FileRepository(TenantDBContext context, IPermissionRepository Permissions)
|
||||
{
|
||||
db = context;
|
||||
this.Permissions = Permissions;
|
||||
_db = context;
|
||||
this._permissions = Permissions;
|
||||
}
|
||||
|
||||
public IEnumerable<File> GetFiles(int FolderId)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Folder", FolderId).ToList();
|
||||
IEnumerable<File> files = db.File.Where(item => item.FolderId == FolderId).Include(item => item.Folder);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Folder", FolderId).ToList();
|
||||
IEnumerable<File> files = _db.File.Where(item => item.FolderId == FolderId).Include(item => item.Folder);
|
||||
foreach (File file in files)
|
||||
{
|
||||
file.Folder.Permissions = Permissions.EncodePermissions(FolderId, permissions);
|
||||
file.Folder.Permissions = _permissions.EncodePermissions(FolderId, permissions);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
public File AddFile(File File)
|
||||
{
|
||||
db.File.Add(File);
|
||||
db.SaveChanges();
|
||||
_db.File.Add(File);
|
||||
_db.SaveChanges();
|
||||
return File;
|
||||
}
|
||||
|
||||
public File UpdateFile(File File)
|
||||
{
|
||||
db.Entry(File).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(File).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return File;
|
||||
}
|
||||
|
||||
public File GetFile(int FileId)
|
||||
{
|
||||
File file = db.File.Where(item => item.FileId == FileId).Include(item => item.Folder).FirstOrDefault();
|
||||
File file = _db.File.Where(item => item.FileId == FileId).Include(item => item.Folder).FirstOrDefault();
|
||||
if (file != null)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Folder", file.FolderId).ToList();
|
||||
file.Folder.Permissions = Permissions.EncodePermissions(file.FolderId, permissions);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Folder", file.FolderId).ToList();
|
||||
file.Folder.Permissions = _permissions.EncodePermissions(file.FolderId, permissions);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
public void DeleteFile(int FileId)
|
||||
{
|
||||
File File = db.File.Find(FileId);
|
||||
db.File.Remove(File);
|
||||
db.SaveChanges();
|
||||
File File = _db.File.Find(FileId);
|
||||
_db.File.Remove(File);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,70 +7,70 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class FolderRepository : IFolderRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private readonly IPermissionRepository Permissions;
|
||||
private TenantDBContext _db;
|
||||
private readonly IPermissionRepository _permissions;
|
||||
|
||||
public FolderRepository(TenantDBContext context, IPermissionRepository Permissions)
|
||||
{
|
||||
db = context;
|
||||
this.Permissions = Permissions;
|
||||
_db = context;
|
||||
this._permissions = Permissions;
|
||||
}
|
||||
|
||||
public IEnumerable<Folder> GetFolders(int SiteId)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions(SiteId, "Folder").ToList();
|
||||
IEnumerable<Folder> folders = db.Folder.Where(item => item.SiteId == SiteId);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(SiteId, "Folder").ToList();
|
||||
IEnumerable<Folder> folders = _db.Folder.Where(item => item.SiteId == SiteId);
|
||||
foreach(Folder folder in folders)
|
||||
{
|
||||
folder.Permissions = Permissions.EncodePermissions(folder.FolderId, permissions);
|
||||
folder.Permissions = _permissions.EncodePermissions(folder.FolderId, permissions);
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
public Folder AddFolder(Folder Folder)
|
||||
{
|
||||
db.Folder.Add(Folder);
|
||||
db.SaveChanges();
|
||||
Permissions.UpdatePermissions(Folder.SiteId, "Folder", Folder.FolderId, Folder.Permissions);
|
||||
_db.Folder.Add(Folder);
|
||||
_db.SaveChanges();
|
||||
_permissions.UpdatePermissions(Folder.SiteId, "Folder", Folder.FolderId, Folder.Permissions);
|
||||
return Folder;
|
||||
}
|
||||
|
||||
public Folder UpdateFolder(Folder Folder)
|
||||
{
|
||||
db.Entry(Folder).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
Permissions.UpdatePermissions(Folder.SiteId, "Folder", Folder.FolderId, Folder.Permissions);
|
||||
_db.Entry(Folder).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
_permissions.UpdatePermissions(Folder.SiteId, "Folder", Folder.FolderId, Folder.Permissions);
|
||||
return Folder;
|
||||
}
|
||||
|
||||
public Folder GetFolder(int FolderId)
|
||||
{
|
||||
Folder folder = db.Folder.Find(FolderId);
|
||||
Folder folder = _db.Folder.Find(FolderId);
|
||||
if (folder != null)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Folder", folder.FolderId).ToList();
|
||||
folder.Permissions = Permissions.EncodePermissions(folder.FolderId, permissions);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Folder", folder.FolderId).ToList();
|
||||
folder.Permissions = _permissions.EncodePermissions(folder.FolderId, permissions);
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
public Folder GetFolder(int SiteId, string Path)
|
||||
{
|
||||
Folder folder = db.Folder.Where(item => item.SiteId == SiteId && item.Path == Path).FirstOrDefault();
|
||||
Folder folder = _db.Folder.Where(item => item.SiteId == SiteId && item.Path == Path).FirstOrDefault();
|
||||
if (folder != null)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Folder", folder.FolderId).ToList();
|
||||
folder.Permissions = Permissions.EncodePermissions(folder.FolderId, permissions);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Folder", folder.FolderId).ToList();
|
||||
folder.Permissions = _permissions.EncodePermissions(folder.FolderId, permissions);
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void DeleteFolder(int FolderId)
|
||||
{
|
||||
Folder Folder = db.Folder.Find(FolderId);
|
||||
Permissions.DeletePermissions(Folder.SiteId, "Folder", FolderId);
|
||||
db.Folder.Remove(Folder);
|
||||
db.SaveChanges();
|
||||
Folder Folder = _db.Folder.Find(FolderId);
|
||||
_permissions.DeletePermissions(Folder.SiteId, "Folder", FolderId);
|
||||
_db.Folder.Remove(Folder);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,45 +7,45 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class JobLogRepository : IJobLogRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
private MasterDBContext _db;
|
||||
|
||||
public JobLogRepository(MasterDBContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<JobLog> GetJobLogs()
|
||||
{
|
||||
return db.JobLog
|
||||
return _db.JobLog
|
||||
.Include(item => item.Job) // eager load jobs
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public JobLog AddJobLog(JobLog JobLog)
|
||||
{
|
||||
db.JobLog.Add(JobLog);
|
||||
db.SaveChanges();
|
||||
_db.JobLog.Add(JobLog);
|
||||
_db.SaveChanges();
|
||||
return JobLog;
|
||||
}
|
||||
|
||||
public JobLog UpdateJobLog(JobLog JobLog)
|
||||
{
|
||||
db.Entry(JobLog).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(JobLog).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return JobLog;
|
||||
}
|
||||
|
||||
public JobLog GetJobLog(int JobLogId)
|
||||
{
|
||||
return db.JobLog.Include(item => item.Job) // eager load job
|
||||
return _db.JobLog.Include(item => item.Job) // eager load job
|
||||
.SingleOrDefault(item => item.JobLogId == JobLogId);
|
||||
}
|
||||
|
||||
public void DeleteJobLog(int JobLogId)
|
||||
{
|
||||
JobLog Joblog = db.JobLog.Find(JobLogId);
|
||||
db.JobLog.Remove(Joblog);
|
||||
db.SaveChanges();
|
||||
JobLog Joblog = _db.JobLog.Find(JobLogId);
|
||||
_db.JobLog.Remove(Joblog);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class JobRepository : IJobRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
private MasterDBContext _db;
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
public JobRepository(MasterDBContext context, IMemoryCache cache)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
|
@ -23,34 +23,34 @@ namespace Oqtane.Repository
|
|||
return _cache.GetOrCreate("jobs", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
||||
return db.Job.ToList();
|
||||
return _db.Job.ToList();
|
||||
});
|
||||
}
|
||||
|
||||
public Job AddJob(Job Job)
|
||||
{
|
||||
db.Job.Add(Job);
|
||||
db.SaveChanges();
|
||||
_db.Job.Add(Job);
|
||||
_db.SaveChanges();
|
||||
return Job;
|
||||
}
|
||||
|
||||
public Job UpdateJob(Job Job)
|
||||
{
|
||||
db.Entry(Job).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Job).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return Job;
|
||||
}
|
||||
|
||||
public Job GetJob(int JobId)
|
||||
{
|
||||
return db.Job.Find(JobId);
|
||||
return _db.Job.Find(JobId);
|
||||
}
|
||||
|
||||
public void DeleteJob(int JobId)
|
||||
{
|
||||
Job Job = db.Job.Find(JobId);
|
||||
db.Job.Remove(Job);
|
||||
db.SaveChanges();
|
||||
Job Job = _db.Job.Find(JobId);
|
||||
_db.Job.Remove(Job);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class LogRepository : ILogRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private TenantDBContext _db;
|
||||
|
||||
public LogRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Log> GetLogs(int SiteId, string Level, string Function, int Rows)
|
||||
|
@ -20,12 +20,12 @@ namespace Oqtane.Repository
|
|||
{
|
||||
if (Function == null)
|
||||
{
|
||||
return db.Log.Where(item => item.SiteId == SiteId).
|
||||
return _db.Log.Where(item => item.SiteId == SiteId).
|
||||
OrderByDescending(item => item.LogDate).Take(Rows);
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.Log.Where(item => item.SiteId == SiteId && item.Function == Function).
|
||||
return _db.Log.Where(item => item.SiteId == SiteId && item.Function == Function).
|
||||
OrderByDescending(item => item.LogDate).Take(Rows);
|
||||
}
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ namespace Oqtane.Repository
|
|||
{
|
||||
if (Function == null)
|
||||
{
|
||||
return db.Log.Where(item => item.SiteId == SiteId && item.Level == Level)
|
||||
return _db.Log.Where(item => item.SiteId == SiteId && item.Level == Level)
|
||||
.OrderByDescending(item => item.LogDate).Take(Rows);
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.Log.Where(item => item.SiteId == SiteId && item.Level == Level && item.Function == Function)
|
||||
return _db.Log.Where(item => item.SiteId == SiteId && item.Level == Level && item.Function == Function)
|
||||
.OrderByDescending(item => item.LogDate).Take(Rows);
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,13 @@ namespace Oqtane.Repository
|
|||
|
||||
public Log GetLog(int LogId)
|
||||
{
|
||||
return db.Log.Find(LogId);
|
||||
return _db.Log.Find(LogId);
|
||||
}
|
||||
|
||||
public void AddLog(Log Log)
|
||||
{
|
||||
db.Log.Add(Log);
|
||||
db.SaveChanges();
|
||||
_db.Log.Add(Log);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class ModuleDefinitionRepository : IModuleDefinitionRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
private MasterDBContext _db;
|
||||
private readonly IMemoryCache _cache;
|
||||
private readonly IPermissionRepository Permissions;
|
||||
private readonly IPermissionRepository _permissions;
|
||||
|
||||
public ModuleDefinitionRepository(MasterDBContext context, IMemoryCache cache, IPermissionRepository Permissions)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
_cache = cache;
|
||||
this.Permissions = Permissions;
|
||||
this._permissions = Permissions;
|
||||
}
|
||||
|
||||
public IEnumerable<ModuleDefinition> GetModuleDefinitions(int SiteId)
|
||||
|
@ -36,16 +36,16 @@ namespace Oqtane.Repository
|
|||
|
||||
public void UpdateModuleDefinition(ModuleDefinition ModuleDefinition)
|
||||
{
|
||||
Permissions.UpdatePermissions(ModuleDefinition.SiteId, "ModuleDefinition", ModuleDefinition.ModuleDefinitionId, ModuleDefinition.Permissions);
|
||||
_permissions.UpdatePermissions(ModuleDefinition.SiteId, "ModuleDefinition", ModuleDefinition.ModuleDefinitionId, ModuleDefinition.Permissions);
|
||||
_cache.Remove("moduledefinitions");
|
||||
}
|
||||
|
||||
public void DeleteModuleDefinition(int ModuleDefinitionId, int SiteId)
|
||||
{
|
||||
ModuleDefinition ModuleDefinition = db.ModuleDefinition.Find(ModuleDefinitionId);
|
||||
Permissions.DeletePermissions(SiteId, "ModuleDefinition", ModuleDefinitionId);
|
||||
db.ModuleDefinition.Remove(ModuleDefinition);
|
||||
db.SaveChanges();
|
||||
ModuleDefinition ModuleDefinition = _db.ModuleDefinition.Find(ModuleDefinitionId);
|
||||
_permissions.DeletePermissions(SiteId, "ModuleDefinition", ModuleDefinitionId);
|
||||
_db.ModuleDefinition.Remove(ModuleDefinition);
|
||||
_db.SaveChanges();
|
||||
_cache.Remove("moduledefinitions");
|
||||
}
|
||||
|
||||
|
@ -60,20 +60,20 @@ namespace Oqtane.Repository
|
|||
});
|
||||
|
||||
// sync module definitions with database
|
||||
List<ModuleDefinition> moduledefs = db.ModuleDefinition.ToList();
|
||||
List<Permission> permissions = Permissions.GetPermissions(SiteId, "ModuleDefinition").ToList();
|
||||
List<ModuleDefinition> moduledefs = _db.ModuleDefinition.ToList();
|
||||
List<Permission> permissions = _permissions.GetPermissions(SiteId, "ModuleDefinition").ToList();
|
||||
foreach (ModuleDefinition moduledefinition in ModuleDefinitions)
|
||||
{
|
||||
ModuleDefinition moduledef = moduledefs.Where(item => item.ModuleDefinitionName == moduledefinition.ModuleDefinitionName).FirstOrDefault();
|
||||
if (moduledef == null)
|
||||
{
|
||||
moduledef = new ModuleDefinition { ModuleDefinitionName = moduledefinition.ModuleDefinitionName };
|
||||
db.ModuleDefinition.Add(moduledef);
|
||||
db.SaveChanges();
|
||||
_db.ModuleDefinition.Add(moduledef);
|
||||
_db.SaveChanges();
|
||||
if (moduledefinition.Permissions != "")
|
||||
{
|
||||
Permissions.UpdatePermissions(SiteId, "ModuleDefinition", moduledef.ModuleDefinitionId, moduledefinition.Permissions);
|
||||
foreach(Permission permission in Permissions.GetPermissions("ModuleDefinition", moduledef.ModuleDefinitionId))
|
||||
_permissions.UpdatePermissions(SiteId, "ModuleDefinition", moduledef.ModuleDefinitionId, moduledefinition.Permissions);
|
||||
foreach(Permission permission in _permissions.GetPermissions("ModuleDefinition", moduledef.ModuleDefinitionId))
|
||||
{
|
||||
permissions.Add(permission);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace Oqtane.Repository
|
|||
}
|
||||
moduledefinition.ModuleDefinitionId = moduledef.ModuleDefinitionId;
|
||||
moduledefinition.SiteId = SiteId;
|
||||
moduledefinition.Permissions = Permissions.EncodePermissions(moduledefinition.ModuleDefinitionId, permissions);
|
||||
moduledefinition.Permissions = _permissions.EncodePermissions(moduledefinition.ModuleDefinitionId, permissions);
|
||||
moduledefinition.CreatedBy = moduledef.CreatedBy;
|
||||
moduledefinition.CreatedOn = moduledef.CreatedOn;
|
||||
moduledefinition.ModifiedBy = moduledef.ModifiedBy;
|
||||
|
@ -95,8 +95,8 @@ namespace Oqtane.Repository
|
|||
// any remaining module definitions are orphans
|
||||
foreach (ModuleDefinition moduledefinition in moduledefs)
|
||||
{
|
||||
Permissions.DeletePermissions(SiteId, "ModuleDefinition", moduledefinition.ModuleDefinitionId);
|
||||
db.ModuleDefinition.Remove(moduledefinition); // delete
|
||||
_permissions.DeletePermissions(SiteId, "ModuleDefinition", moduledefinition.ModuleDefinitionId);
|
||||
_db.ModuleDefinition.Remove(moduledefinition); // delete
|
||||
}
|
||||
|
||||
return ModuleDefinitions;
|
||||
|
|
|
@ -12,57 +12,57 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class ModuleRepository : IModuleRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private readonly IPermissionRepository Permissions;
|
||||
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
||||
private readonly IServiceProvider ServiceProvider;
|
||||
private TenantDBContext _db;
|
||||
private readonly IPermissionRepository _permissions;
|
||||
private readonly IModuleDefinitionRepository _moduleDefinitions;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public ModuleRepository(TenantDBContext context, IPermissionRepository Permissions, IModuleDefinitionRepository ModuleDefinitions, IServiceProvider ServiceProvider)
|
||||
{
|
||||
db = context;
|
||||
this.Permissions = Permissions;
|
||||
this.ModuleDefinitions = ModuleDefinitions;
|
||||
this.ServiceProvider = ServiceProvider;
|
||||
_db = context;
|
||||
this._permissions = Permissions;
|
||||
this._moduleDefinitions = ModuleDefinitions;
|
||||
this._serviceProvider = ServiceProvider;
|
||||
}
|
||||
|
||||
public IEnumerable<Models.Module> GetModules(int SiteId)
|
||||
{
|
||||
return db.Module.Where(item => item.SiteId == SiteId).ToList();
|
||||
return _db.Module.Where(item => item.SiteId == SiteId).ToList();
|
||||
}
|
||||
|
||||
public Models.Module AddModule(Models.Module Module)
|
||||
{
|
||||
db.Module.Add(Module);
|
||||
db.SaveChanges();
|
||||
Permissions.UpdatePermissions(Module.SiteId, "Module", Module.ModuleId, Module.Permissions);
|
||||
_db.Module.Add(Module);
|
||||
_db.SaveChanges();
|
||||
_permissions.UpdatePermissions(Module.SiteId, "Module", Module.ModuleId, Module.Permissions);
|
||||
return Module;
|
||||
}
|
||||
|
||||
public Models.Module UpdateModule(Models.Module Module)
|
||||
{
|
||||
db.Entry(Module).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
Permissions.UpdatePermissions(Module.SiteId, "Module", Module.ModuleId, Module.Permissions);
|
||||
_db.Entry(Module).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
_permissions.UpdatePermissions(Module.SiteId, "Module", Module.ModuleId, Module.Permissions);
|
||||
return Module;
|
||||
}
|
||||
|
||||
public Models.Module GetModule(int ModuleId)
|
||||
{
|
||||
Models.Module module = db.Module.Find(ModuleId);
|
||||
Models.Module module = _db.Module.Find(ModuleId);
|
||||
if (module != null)
|
||||
{
|
||||
List<Permission> permissions = Permissions.GetPermissions("Module", module.ModuleId).ToList();
|
||||
module.Permissions = Permissions.EncodePermissions(module.ModuleId, permissions);
|
||||
List<Permission> permissions = _permissions.GetPermissions("Module", module.ModuleId).ToList();
|
||||
module.Permissions = _permissions.EncodePermissions(module.ModuleId, permissions);
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
public void DeleteModule(int ModuleId)
|
||||
{
|
||||
Models.Module Module = db.Module.Find(ModuleId);
|
||||
Permissions.DeletePermissions(Module.SiteId, "Module", ModuleId);
|
||||
db.Module.Remove(Module);
|
||||
db.SaveChanges();
|
||||
Models.Module Module = _db.Module.Find(ModuleId);
|
||||
_permissions.DeletePermissions(Module.SiteId, "Module", ModuleId);
|
||||
_db.Module.Remove(Module);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
public string ExportModule(int ModuleId)
|
||||
|
@ -73,7 +73,7 @@ namespace Oqtane.Repository
|
|||
Models.Module module = GetModule(ModuleId);
|
||||
if (module != null)
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault();
|
||||
if (moduledefinition != null)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ namespace Oqtane.Repository
|
|||
.Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault();
|
||||
if (moduletype != null)
|
||||
{
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype);
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
||||
modulecontent.Content = ((IPortable)moduleobject).ExportModule(module);
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ namespace Oqtane.Repository
|
|||
Models.Module module = GetModule(ModuleId);
|
||||
if (module != null)
|
||||
{
|
||||
List<ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList();
|
||||
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault();
|
||||
if (moduledefinition != null)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ namespace Oqtane.Repository
|
|||
.Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault();
|
||||
if (moduletype != null)
|
||||
{
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype);
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
||||
((IPortable)moduleobject).ImportModule(module, modulecontent.Content, modulecontent.Version);
|
||||
success = true;
|
||||
}
|
||||
|
|
|
@ -7,18 +7,18 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class NotificationRepository : INotificationRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private TenantDBContext _db;
|
||||
|
||||
public NotificationRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Notification> GetNotifications(int SiteId, int FromUserId, int ToUserId)
|
||||
{
|
||||
if (ToUserId == -1 && FromUserId == -1)
|
||||
{
|
||||
return db.Notification
|
||||
return _db.Notification
|
||||
.Where(item => item.SiteId == SiteId)
|
||||
.Where(item => item.IsDelivered == false)
|
||||
.Include(item => item.FromUser)
|
||||
|
@ -27,7 +27,7 @@ namespace Oqtane.Repository
|
|||
}
|
||||
else
|
||||
{
|
||||
return db.Notification
|
||||
return _db.Notification
|
||||
.Where(item => item.SiteId == SiteId)
|
||||
.Where(item => item.ToUserId == ToUserId || ToUserId == -1)
|
||||
.Where(item => item.FromUserId == FromUserId || FromUserId == -1)
|
||||
|
@ -39,28 +39,28 @@ namespace Oqtane.Repository
|
|||
|
||||
public Notification AddNotification(Notification Notification)
|
||||
{
|
||||
db.Notification.Add(Notification);
|
||||
db.SaveChanges();
|
||||
_db.Notification.Add(Notification);
|
||||
_db.SaveChanges();
|
||||
return Notification;
|
||||
}
|
||||
|
||||
public Notification UpdateNotification(Notification Notification)
|
||||
{
|
||||
db.Entry(Notification).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Notification).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return Notification;
|
||||
}
|
||||
|
||||
public Notification GetNotification(int NotificationId)
|
||||
{
|
||||
return db.Notification.Find(NotificationId);
|
||||
return _db.Notification.Find(NotificationId);
|
||||
}
|
||||
|
||||
public void DeleteNotification(int NotificationId)
|
||||
{
|
||||
Notification Notification = db.Notification.Find(NotificationId);
|
||||
db.Notification.Remove(Notification);
|
||||
db.SaveChanges();
|
||||
Notification Notification = _db.Notification.Find(NotificationId);
|
||||
_db.Notification.Remove(Notification);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,26 +7,26 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class PageModuleRepository : IPageModuleRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private readonly IPermissionRepository Permissions;
|
||||
private TenantDBContext _db;
|
||||
private readonly IPermissionRepository _permissions;
|
||||
|
||||
public PageModuleRepository(TenantDBContext context, IPermissionRepository Permissions)
|
||||
{
|
||||
db = context;
|
||||
this.Permissions = Permissions;
|
||||
_db = context;
|
||||
this._permissions = Permissions;
|
||||
}
|
||||
|
||||
public IEnumerable<PageModule> GetPageModules(int SiteId)
|
||||
{
|
||||
IEnumerable<PageModule> pagemodules = db.PageModule
|
||||
IEnumerable<PageModule> pagemodules = _db.PageModule
|
||||
.Include(item => item.Module) // eager load modules
|
||||
.Where(item => item.Module.SiteId == SiteId);
|
||||
if (pagemodules != null && pagemodules.Any())
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions(pagemodules.FirstOrDefault().Module.SiteId, "Module").ToList();
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(pagemodules.FirstOrDefault().Module.SiteId, "Module").ToList();
|
||||
foreach (PageModule pagemodule in pagemodules)
|
||||
{
|
||||
pagemodule.Module.Permissions = Permissions.EncodePermissions(pagemodule.ModuleId, permissions);
|
||||
pagemodule.Module.Permissions = _permissions.EncodePermissions(pagemodule.ModuleId, permissions);
|
||||
}
|
||||
}
|
||||
return pagemodules;
|
||||
|
@ -34,7 +34,7 @@ namespace Oqtane.Repository
|
|||
|
||||
public IEnumerable<PageModule> GetPageModules(int PageId, string Pane)
|
||||
{
|
||||
IEnumerable<PageModule> pagemodules = db.PageModule
|
||||
IEnumerable<PageModule> pagemodules = _db.PageModule
|
||||
.Include(item => item.Module) // eager load modules
|
||||
.Where(item => item.PageId == PageId);
|
||||
if (Pane != "" && pagemodules != null && pagemodules.Any())
|
||||
|
@ -43,10 +43,10 @@ namespace Oqtane.Repository
|
|||
}
|
||||
if (pagemodules != null && pagemodules.Any())
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions(pagemodules.FirstOrDefault().Module.SiteId, "Module").ToList();
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(pagemodules.FirstOrDefault().Module.SiteId, "Module").ToList();
|
||||
foreach (PageModule pagemodule in pagemodules)
|
||||
{
|
||||
pagemodule.Module.Permissions = Permissions.EncodePermissions(pagemodule.ModuleId, permissions);
|
||||
pagemodule.Module.Permissions = _permissions.EncodePermissions(pagemodule.ModuleId, permissions);
|
||||
}
|
||||
}
|
||||
return pagemodules;
|
||||
|
@ -54,47 +54,47 @@ namespace Oqtane.Repository
|
|||
|
||||
public PageModule AddPageModule(PageModule PageModule)
|
||||
{
|
||||
db.PageModule.Add(PageModule);
|
||||
db.SaveChanges();
|
||||
_db.PageModule.Add(PageModule);
|
||||
_db.SaveChanges();
|
||||
return PageModule;
|
||||
}
|
||||
|
||||
public PageModule UpdatePageModule(PageModule PageModule)
|
||||
{
|
||||
db.Entry(PageModule).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(PageModule).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return PageModule;
|
||||
}
|
||||
|
||||
public PageModule GetPageModule(int PageModuleId)
|
||||
{
|
||||
PageModule pagemodule = db.PageModule.Include(item => item.Module) // eager load modules
|
||||
PageModule pagemodule = _db.PageModule.Include(item => item.Module) // eager load modules
|
||||
.SingleOrDefault(item => item.PageModuleId == PageModuleId);
|
||||
if (pagemodule != null)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Module", pagemodule.ModuleId).ToList();
|
||||
pagemodule.Module.Permissions = Permissions.EncodePermissions(pagemodule.ModuleId, permissions);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Module", pagemodule.ModuleId).ToList();
|
||||
pagemodule.Module.Permissions = _permissions.EncodePermissions(pagemodule.ModuleId, permissions);
|
||||
}
|
||||
return pagemodule;
|
||||
}
|
||||
|
||||
public PageModule GetPageModule(int PageId, int ModuleId)
|
||||
{
|
||||
PageModule pagemodule = db.PageModule.Include(item => item.Module) // eager load modules
|
||||
PageModule pagemodule = _db.PageModule.Include(item => item.Module) // eager load modules
|
||||
.SingleOrDefault(item => item.PageId == PageId && item.ModuleId == ModuleId);
|
||||
if (pagemodule != null)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Module", pagemodule.ModuleId).ToList();
|
||||
pagemodule.Module.Permissions = Permissions.EncodePermissions(pagemodule.ModuleId, permissions);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Module", pagemodule.ModuleId).ToList();
|
||||
pagemodule.Module.Permissions = _permissions.EncodePermissions(pagemodule.ModuleId, permissions);
|
||||
}
|
||||
return pagemodule;
|
||||
}
|
||||
|
||||
public void DeletePageModule(int PageModuleId)
|
||||
{
|
||||
PageModule PageModule = db.PageModule.Find(PageModuleId);
|
||||
db.PageModule.Remove(PageModule);
|
||||
db.SaveChanges();
|
||||
PageModule PageModule = _db.PageModule.Find(PageModuleId);
|
||||
_db.PageModule.Remove(PageModule);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,69 +7,69 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class PageRepository : IPageRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private readonly IPermissionRepository Permissions;
|
||||
private readonly IPageModuleRepository PageModules;
|
||||
private TenantDBContext _db;
|
||||
private readonly IPermissionRepository _permissions;
|
||||
private readonly IPageModuleRepository _pageModules;
|
||||
|
||||
public PageRepository(TenantDBContext context, IPermissionRepository Permissions, IPageModuleRepository PageModules)
|
||||
{
|
||||
db = context;
|
||||
this.Permissions = Permissions;
|
||||
this.PageModules = PageModules;
|
||||
_db = context;
|
||||
this._permissions = Permissions;
|
||||
this._pageModules = PageModules;
|
||||
}
|
||||
|
||||
public IEnumerable<Page> GetPages(int SiteId)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions(SiteId, "Page").ToList();
|
||||
IEnumerable<Page> pages = db.Page.Where(item => item.SiteId == SiteId && item.UserId == null);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions(SiteId, "Page").ToList();
|
||||
IEnumerable<Page> pages = _db.Page.Where(item => item.SiteId == SiteId && item.UserId == null);
|
||||
foreach(Page page in pages)
|
||||
{
|
||||
page.Permissions = Permissions.EncodePermissions(page.PageId, permissions);
|
||||
page.Permissions = _permissions.EncodePermissions(page.PageId, permissions);
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
|
||||
public Page AddPage(Page Page)
|
||||
{
|
||||
db.Page.Add(Page);
|
||||
db.SaveChanges();
|
||||
Permissions.UpdatePermissions(Page.SiteId, "Page", Page.PageId, Page.Permissions);
|
||||
_db.Page.Add(Page);
|
||||
_db.SaveChanges();
|
||||
_permissions.UpdatePermissions(Page.SiteId, "Page", Page.PageId, Page.Permissions);
|
||||
return Page;
|
||||
}
|
||||
|
||||
public Page UpdatePage(Page Page)
|
||||
{
|
||||
db.Entry(Page).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
Permissions.UpdatePermissions(Page.SiteId, "Page", Page.PageId, Page.Permissions);
|
||||
_db.Entry(Page).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
_permissions.UpdatePermissions(Page.SiteId, "Page", Page.PageId, Page.Permissions);
|
||||
return Page;
|
||||
}
|
||||
|
||||
public Page GetPage(int PageId)
|
||||
{
|
||||
Page page = db.Page.Find(PageId);
|
||||
Page page = _db.Page.Find(PageId);
|
||||
if (page != null)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Page", page.PageId).ToList();
|
||||
page.Permissions = Permissions.EncodePermissions(page.PageId, permissions);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Page", page.PageId).ToList();
|
||||
page.Permissions = _permissions.EncodePermissions(page.PageId, permissions);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page GetPage(int PageId, int UserId)
|
||||
{
|
||||
Page page = db.Page.Find(PageId);
|
||||
Page page = _db.Page.Find(PageId);
|
||||
if (page != null)
|
||||
{
|
||||
Page personalized = db.Page.Where(item => item.SiteId == page.SiteId && item.Path == page.Path && item.UserId == UserId).FirstOrDefault();
|
||||
Page personalized = _db.Page.Where(item => item.SiteId == page.SiteId && item.Path == page.Path && item.UserId == UserId).FirstOrDefault();
|
||||
if (personalized != null)
|
||||
{
|
||||
page = personalized;
|
||||
}
|
||||
if (page != null)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Page", page.PageId).ToList();
|
||||
page.Permissions = Permissions.EncodePermissions(page.PageId, permissions);
|
||||
IEnumerable<Permission> permissions = _permissions.GetPermissions("Page", page.PageId).ToList();
|
||||
page.Permissions = _permissions.EncodePermissions(page.PageId, permissions);
|
||||
}
|
||||
}
|
||||
return page;
|
||||
|
@ -77,15 +77,15 @@ namespace Oqtane.Repository
|
|||
|
||||
public void DeletePage(int PageId)
|
||||
{
|
||||
Page Page = db.Page.Find(PageId);
|
||||
Permissions.DeletePermissions(Page.SiteId, "Page", PageId);
|
||||
IEnumerable<PageModule> pageModules = db.PageModule.Where(item => item.PageId == PageId).ToList();
|
||||
Page Page = _db.Page.Find(PageId);
|
||||
_permissions.DeletePermissions(Page.SiteId, "Page", PageId);
|
||||
IEnumerable<PageModule> pageModules = _db.PageModule.Where(item => item.PageId == PageId).ToList();
|
||||
foreach (var pageModule in pageModules)
|
||||
{
|
||||
PageModules.DeletePageModule(pageModule.PageModuleId);
|
||||
_pageModules.DeletePageModule(pageModule.PageModuleId);
|
||||
}
|
||||
db.Page.Remove(Page);
|
||||
db.SaveChanges();
|
||||
_db.Page.Remove(Page);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,32 +11,32 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class PermissionRepository : IPermissionRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private readonly IRoleRepository Roles;
|
||||
private TenantDBContext _db;
|
||||
private readonly IRoleRepository _roles;
|
||||
|
||||
public PermissionRepository(TenantDBContext context, IRoleRepository Roles)
|
||||
{
|
||||
db = context;
|
||||
this.Roles = Roles;
|
||||
_db = context;
|
||||
this._roles = Roles;
|
||||
}
|
||||
|
||||
public IEnumerable<Permission> GetPermissions(int SiteId, string EntityName)
|
||||
{
|
||||
return db.Permission.Where(item => item.SiteId == SiteId)
|
||||
return _db.Permission.Where(item => item.SiteId == SiteId)
|
||||
.Where(item => item.EntityName == EntityName)
|
||||
.Include(item => item.Role); // eager load roles
|
||||
}
|
||||
|
||||
public IEnumerable<Permission> GetPermissions(string EntityName, int EntityId)
|
||||
{
|
||||
return db.Permission.Where(item => item.EntityName == EntityName)
|
||||
return _db.Permission.Where(item => item.EntityName == EntityName)
|
||||
.Where(item => item.EntityId == EntityId)
|
||||
.Include(item => item.Role); // eager load roles
|
||||
}
|
||||
|
||||
public IEnumerable<Permission> GetPermissions(string EntityName, int EntityId, string PermissionName)
|
||||
{
|
||||
return db.Permission.Where(item => item.EntityName == EntityName)
|
||||
return _db.Permission.Where(item => item.EntityName == EntityName)
|
||||
.Where(item => item.EntityId == EntityId)
|
||||
.Where(item => item.PermissionName == PermissionName)
|
||||
.Include(item => item.Role); // eager load roles
|
||||
|
@ -44,61 +44,61 @@ namespace Oqtane.Repository
|
|||
|
||||
public Permission AddPermission(Permission Permission)
|
||||
{
|
||||
db.Permission.Add(Permission);
|
||||
db.SaveChanges();
|
||||
_db.Permission.Add(Permission);
|
||||
_db.SaveChanges();
|
||||
return Permission;
|
||||
}
|
||||
|
||||
public Permission UpdatePermission(Permission Permission)
|
||||
{
|
||||
db.Entry(Permission).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Permission).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return Permission;
|
||||
}
|
||||
|
||||
public void UpdatePermissions(int SiteId, string EntityName, int EntityId, string Permissions)
|
||||
{
|
||||
// get current permissions and delete
|
||||
IEnumerable<Permission> permissions = db.Permission
|
||||
IEnumerable<Permission> permissions = _db.Permission
|
||||
.Where(item => item.EntityName == EntityName)
|
||||
.Where(item => item.EntityId == EntityId)
|
||||
.Where(item => item.SiteId == SiteId);
|
||||
foreach (Permission permission in permissions)
|
||||
{
|
||||
db.Permission.Remove(permission);
|
||||
_db.Permission.Remove(permission);
|
||||
}
|
||||
// add permissions
|
||||
permissions = DecodePermissions(Permissions, SiteId, EntityName, EntityId);
|
||||
foreach (Permission permission in permissions)
|
||||
{
|
||||
db.Permission.Add(permission);
|
||||
_db.Permission.Add(permission);
|
||||
}
|
||||
db.SaveChanges();
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
public Permission GetPermission(int PermissionId)
|
||||
{
|
||||
return db.Permission.Find(PermissionId);
|
||||
return _db.Permission.Find(PermissionId);
|
||||
}
|
||||
|
||||
public void DeletePermission(int PermissionId)
|
||||
{
|
||||
Permission Permission = db.Permission.Find(PermissionId);
|
||||
db.Permission.Remove(Permission);
|
||||
db.SaveChanges();
|
||||
Permission Permission = _db.Permission.Find(PermissionId);
|
||||
_db.Permission.Remove(Permission);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
public void DeletePermissions(int SiteId, string EntityName, int EntityId)
|
||||
{
|
||||
IEnumerable<Permission> permissions = db.Permission
|
||||
IEnumerable<Permission> permissions = _db.Permission
|
||||
.Where(item => item.EntityName == EntityName)
|
||||
.Where(item => item.EntityId == EntityId)
|
||||
.Where(item => item.SiteId == SiteId);
|
||||
foreach (Permission permission in permissions)
|
||||
{
|
||||
db.Permission.Remove(permission);
|
||||
_db.Permission.Remove(permission);
|
||||
}
|
||||
db.SaveChanges();
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
// permissions are stored in the format "{permissionname:!rolename1;![userid1];rolename2;rolename3;[userid2];[userid3]}" where "!" designates Deny permissions
|
||||
|
@ -158,7 +158,7 @@ namespace Oqtane.Repository
|
|||
public IEnumerable<Permission> DecodePermissions(string PermissionStrings, int SiteId, string EntityName, int EntityId)
|
||||
{
|
||||
List<Permission> permissions = new List<Permission>();
|
||||
List<Role> roles = Roles.GetRoles(SiteId, true).ToList();
|
||||
List<Role> roles = _roles.GetRoles(SiteId, true).ToList();
|
||||
string securityid = "";
|
||||
foreach (PermissionString permissionstring in JsonSerializer.Deserialize<List<PermissionString>>(PermissionStrings))
|
||||
{
|
||||
|
|
|
@ -7,42 +7,42 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class ProfileRepository : IProfileRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private TenantDBContext _db;
|
||||
|
||||
public ProfileRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Profile> GetProfiles(int SiteId)
|
||||
{
|
||||
return db.Profile.Where(item => item.SiteId == SiteId || item.SiteId == null);
|
||||
return _db.Profile.Where(item => item.SiteId == SiteId || item.SiteId == null);
|
||||
}
|
||||
|
||||
public Profile AddProfile(Profile Profile)
|
||||
{
|
||||
db.Profile.Add(Profile);
|
||||
db.SaveChanges();
|
||||
_db.Profile.Add(Profile);
|
||||
_db.SaveChanges();
|
||||
return Profile;
|
||||
}
|
||||
|
||||
public Profile UpdateProfile(Profile Profile)
|
||||
{
|
||||
db.Entry(Profile).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Profile).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return Profile;
|
||||
}
|
||||
|
||||
public Profile GetProfile(int ProfileId)
|
||||
{
|
||||
return db.Profile.Find(ProfileId);
|
||||
return _db.Profile.Find(ProfileId);
|
||||
}
|
||||
|
||||
public void DeleteProfile(int ProfileId)
|
||||
{
|
||||
Profile Profile = db.Profile.Find(ProfileId);
|
||||
db.Profile.Remove(Profile);
|
||||
db.SaveChanges();
|
||||
Profile Profile = _db.Profile.Find(ProfileId);
|
||||
_db.Profile.Remove(Profile);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,48 +7,48 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class RoleRepository : IRoleRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private TenantDBContext _db;
|
||||
|
||||
public RoleRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Role> GetRoles(int SiteId)
|
||||
{
|
||||
return db.Role.Where(item => item.SiteId == SiteId);
|
||||
return _db.Role.Where(item => item.SiteId == SiteId);
|
||||
}
|
||||
|
||||
public IEnumerable<Role> GetRoles(int SiteId, bool IncludeGlobalRoles)
|
||||
{
|
||||
return db.Role.Where(item => item.SiteId == SiteId || item.SiteId == null);
|
||||
return _db.Role.Where(item => item.SiteId == SiteId || item.SiteId == null);
|
||||
}
|
||||
|
||||
|
||||
public Role AddRole(Role Role)
|
||||
{
|
||||
db.Role.Add(Role);
|
||||
db.SaveChanges();
|
||||
_db.Role.Add(Role);
|
||||
_db.SaveChanges();
|
||||
return Role;
|
||||
}
|
||||
|
||||
public Role UpdateRole(Role Role)
|
||||
{
|
||||
db.Entry(Role).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Role).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return Role;
|
||||
}
|
||||
|
||||
public Role GetRole(int RoleId)
|
||||
{
|
||||
return db.Role.Find(RoleId);
|
||||
return _db.Role.Find(RoleId);
|
||||
}
|
||||
|
||||
public void DeleteRole(int RoleId)
|
||||
{
|
||||
Role Role = db.Role.Find(RoleId);
|
||||
db.Role.Remove(Role);
|
||||
db.SaveChanges();
|
||||
Role Role = _db.Role.Find(RoleId);
|
||||
_db.Role.Remove(Role);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,43 +7,43 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class SettingRepository : ISettingRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private TenantDBContext _db;
|
||||
|
||||
public SettingRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Setting> GetSettings(string EntityName, int EntityId)
|
||||
{
|
||||
return db.Setting.Where(item => item.EntityName == EntityName)
|
||||
return _db.Setting.Where(item => item.EntityName == EntityName)
|
||||
.Where(item => item.EntityId == EntityId);
|
||||
}
|
||||
|
||||
public Setting AddSetting(Setting Setting)
|
||||
{
|
||||
db.Setting.Add(Setting);
|
||||
db.SaveChanges();
|
||||
_db.Setting.Add(Setting);
|
||||
_db.SaveChanges();
|
||||
return Setting;
|
||||
}
|
||||
|
||||
public Setting UpdateSetting(Setting Setting)
|
||||
{
|
||||
db.Entry(Setting).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Setting).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return Setting;
|
||||
}
|
||||
|
||||
public Setting GetSetting(int SettingId)
|
||||
{
|
||||
return db.Setting.Find(SettingId);
|
||||
return _db.Setting.Find(SettingId);
|
||||
}
|
||||
|
||||
public void DeleteSetting(int SettingId)
|
||||
{
|
||||
Setting Setting = db.Setting.Find(SettingId);
|
||||
db.Setting.Remove(Setting);
|
||||
db.SaveChanges();
|
||||
Setting Setting = _db.Setting.Find(SettingId);
|
||||
_db.Setting.Remove(Setting);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,34 +12,34 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class SiteRepository : ISiteRepository
|
||||
{
|
||||
private readonly TenantDBContext db;
|
||||
private readonly IRoleRepository RoleRepository;
|
||||
private readonly IProfileRepository ProfileRepository;
|
||||
private readonly IFolderRepository FolderRepository;
|
||||
private readonly IFileRepository FileRepository;
|
||||
private readonly IPageRepository PageRepository;
|
||||
private readonly IModuleRepository ModuleRepository;
|
||||
private readonly IPageModuleRepository PageModuleRepository;
|
||||
private readonly IModuleDefinitionRepository ModuleDefinitionRepository;
|
||||
private readonly IServiceProvider ServiceProvider;
|
||||
private readonly List<PageTemplate> SiteTemplate;
|
||||
private readonly TenantDBContext _db;
|
||||
private readonly IRoleRepository _roleRepository;
|
||||
private readonly IProfileRepository _profileRepository;
|
||||
private readonly IFolderRepository _folderRepository;
|
||||
private readonly IFileRepository _fileRepository;
|
||||
private readonly IPageRepository _pageRepository;
|
||||
private readonly IModuleRepository _moduleRepository;
|
||||
private readonly IPageModuleRepository _pageModuleRepository;
|
||||
private readonly IModuleDefinitionRepository _moduleDefinitionRepository;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly List<PageTemplate> _siteTemplate;
|
||||
|
||||
public SiteRepository(TenantDBContext context, IRoleRepository RoleRepository, IProfileRepository ProfileRepository, IFolderRepository FolderRepository, IFileRepository FileRepository, IPageRepository PageRepository, IModuleRepository ModuleRepository, IPageModuleRepository PageModuleRepository, IModuleDefinitionRepository ModuleDefinitionRepository, IServiceProvider ServiceProvider)
|
||||
{
|
||||
db = context;
|
||||
this.RoleRepository = RoleRepository;
|
||||
this.ProfileRepository = ProfileRepository;
|
||||
this.FolderRepository = FolderRepository;
|
||||
this.FileRepository = FileRepository;
|
||||
this.PageRepository = PageRepository;
|
||||
this.ModuleRepository = ModuleRepository;
|
||||
this.PageModuleRepository = PageModuleRepository;
|
||||
this.ModuleDefinitionRepository = ModuleDefinitionRepository;
|
||||
this.ServiceProvider = ServiceProvider;
|
||||
_db = context;
|
||||
this._roleRepository = RoleRepository;
|
||||
this._profileRepository = ProfileRepository;
|
||||
this._folderRepository = FolderRepository;
|
||||
this._fileRepository = FileRepository;
|
||||
this._pageRepository = PageRepository;
|
||||
this._moduleRepository = ModuleRepository;
|
||||
this._pageModuleRepository = PageModuleRepository;
|
||||
this._moduleDefinitionRepository = ModuleDefinitionRepository;
|
||||
this._serviceProvider = ServiceProvider;
|
||||
|
||||
// define the default site template
|
||||
SiteTemplate = new List<PageTemplate>();
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Home", Parent = "", Path = "", Icon = "home", IsNavigation = true, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate = new List<PageTemplate>();
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Home", Parent = "", Path = "", Icon = "home", IsNavigation = true, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Welcome To Oqtane...", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
||||
Content = "<p><a href=\"https://www.oqtane.org\" target=\"_new\">Oqtane</a> is an open source <b>modular application framework</b> built from the ground up using modern .NET Core technology. It leverages the revolutionary new Blazor component model to create a <b>fully dynamic</b> web development experience which can be executed on a client or server. Whether you are looking for a platform to <b>accelerate your web development</b> efforts, or simply interested in exploring the anatomy of a large-scale Blazor application, Oqtane provides a solid foundation based on proven enterprise architectural principles.</p>" +
|
||||
"<p align=\"center\"><a href=\"https://www.oqtane.org\" target=\"_new\"><img src=\"oqtane.png\"></a><br /><br /><a class=\"btn btn-primary\" href=\"https://www.oqtane.org/Community\" target=\"_new\">Join Our Community</a> <a class=\"btn btn-primary\" href=\"https://github.com/oqtane/oqtane.framework\" target=\"_new\">Clone Our Repo</a><br /><br /></p>" +
|
||||
|
@ -54,149 +54,149 @@ namespace Oqtane.Repository
|
|||
}
|
||||
}
|
||||
});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Private", Parent = "", Path = "private", Icon = "lock-locked", IsNavigation = true, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Registered Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Private", Parent = "", Path = "private", Icon = "lock-locked", IsNavigation = true, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Registered Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "Secure Content", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Registered Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
||||
Content = "<p>Oqtane allows you to control access to your content using security roles. This page is only visible to Registered Users of the site.</p>"
|
||||
}
|
||||
}
|
||||
});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "My Page", Parent = "", Path = "mypage", Icon = "target", IsNavigation = true, IsPersonalizable = true, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "My Page", Parent = "", Path = "mypage", Icon = "target", IsNavigation = true, IsPersonalizable = true, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.HtmlText, Oqtane.Client", Title = "My Page", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]",
|
||||
Content = "<p>Oqtane offers native support for user personalized pages. If a page is identified as personalizable by the site administrator in the page settings, when an authenticated user visits the page they will see an edit button at the top right corner of the page next to their username. When they click this button the sytem will create a new version of the page and allow them to edit the page content.</p>"
|
||||
}
|
||||
}
|
||||
});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Admin", Parent = "", Path = "admin", Icon = "", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Admin", Parent = "", Path = "admin", Icon = "", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Dashboard, Oqtane.Client", Title = "Admin Dashboard", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Site Management", Parent = "Admin", Path = "admin/sites", Icon = "globe", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Site Management", Parent = "Admin", Path = "admin/sites", Icon = "globe", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Sites, Oqtane.Client", Title = "Site Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Site Settings", Parent = "Admin", Path = "admin/site", Icon = "home", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Site Settings", Parent = "Admin", Path = "admin/site", Icon = "home", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Site, Oqtane.Client", Title = "Site Settings", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Page Management", Parent = "Admin", Path = "admin/pages", Icon = "layers", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Page Management", Parent = "Admin", Path = "admin/pages", Icon = "layers", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Pages, Oqtane.Client", Title = "Page Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "User Management", Parent = "Admin", Path = "admin/users", Icon = "people", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "User Management", Parent = "Admin", Path = "admin/users", Icon = "people", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Users, Oqtane.Client", Title = "User Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Profile Management", Parent = "Admin", Path = "admin/profiles", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Profile Management", Parent = "Admin", Path = "admin/profiles", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Profiles, Oqtane.Client", Title = "Profile Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Role Management", Parent = "Admin", Path = "admin/roles", Icon = "lock-locked", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Role Management", Parent = "Admin", Path = "admin/roles", Icon = "lock-locked", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Roles, Oqtane.Client", Title = "Role Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Event Log", Parent = "Admin", Path = "admin/log", Icon = "magnifying-glass", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Event Log", Parent = "Admin", Path = "admin/log", Icon = "magnifying-glass", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Logs, Oqtane.Client", Title = "Event Log", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "File Management", Parent = "Admin", Path = "admin/files", Icon = "file", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "File Management", Parent = "Admin", Path = "admin/files", Icon = "file", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Files, Oqtane.Client", Title = "File Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Recycle Bin", Parent = "Admin", Path = "admin/recyclebin", Icon = "trash", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Recycle Bin", Parent = "Admin", Path = "admin/recyclebin", Icon = "trash", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.RecycleBin, Oqtane.Client", Title = "Recycle Bin", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Tenant Management", Parent = "Admin", Path = "admin/tenants", Icon = "list", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Tenant Management", Parent = "Admin", Path = "admin/tenants", Icon = "list", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Tenants, Oqtane.Client", Title = "Tenant Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Module Management", Parent = "Admin", Path = "admin/modules", Icon = "browser", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Module Management", Parent = "Admin", Path = "admin/modules", Icon = "browser", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.ModuleDefinitions, Oqtane.Client", Title = "Module Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Icon = "brush", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Theme Management", Parent = "Admin", Path = "admin/themes", Icon = "brush", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Themes, Oqtane.Client", Title = "Theme Management", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Scheduled Jobs", Parent = "Admin", Path = "admin/jobs", Icon = "timer", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Scheduled Jobs", Parent = "Admin", Path = "admin/jobs", Icon = "timer", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Jobs, Oqtane.Client", Title = "Scheduled Jobs", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Upgrade Service", Parent = "Admin", Path = "admin/upgrade", Icon = "aperture", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Upgrade Service", Parent = "Admin", Path = "admin/upgrade", Icon = "aperture", IsNavigation = false, IsPersonalizable = false, EditMode = true, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Upgrade, Oqtane.Client", Title = "Upgrade Service", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Login", Parent = "", Path = "login", Icon = "lock-locked", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Login", Parent = "", Path = "login", Icon = "lock-locked", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Login, Oqtane.Client", Title = "User Login", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Register", Parent = "", Path = "register", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Register", Parent = "", Path = "register", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Register, Oqtane.Client", Title = "User Registration", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Reset", Parent = "", Path = "reset", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Reset", Parent = "", Path = "reset", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Reset, Oqtane.Client", Title = "Password Reset", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Profile", Parent = "", Path = "profile", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
_siteTemplate.Add(new PageTemplate { Name = "Profile", Parent = "", Path = "profile", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.UserProfile, Oqtane.Client", Title = "User Profile", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
}
|
||||
|
||||
public IEnumerable<Site> GetSites()
|
||||
{
|
||||
return db.Site;
|
||||
return _db.Site;
|
||||
}
|
||||
|
||||
public Site AddSite(Site Site)
|
||||
{
|
||||
db.Site.Add(Site);
|
||||
db.SaveChanges();
|
||||
_db.Site.Add(Site);
|
||||
_db.SaveChanges();
|
||||
CreateSite(Site);
|
||||
return Site;
|
||||
}
|
||||
|
||||
public Site UpdateSite(Site Site)
|
||||
{
|
||||
db.Entry(Site).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Site).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return Site;
|
||||
}
|
||||
|
||||
public Site GetSite(int siteId)
|
||||
{
|
||||
return db.Site.Find(siteId);
|
||||
return _db.Site.Find(siteId);
|
||||
}
|
||||
|
||||
public void DeleteSite(int siteId)
|
||||
{
|
||||
var site = db.Site.Find(siteId);
|
||||
db.Site.Remove(site);
|
||||
db.SaveChanges();
|
||||
var site = _db.Site.Find(siteId);
|
||||
_db.Site.Remove(site);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
private void CreateSite(Site site)
|
||||
{
|
||||
List<Role> roles = RoleRepository.GetRoles(site.SiteId, true).ToList();
|
||||
List<Role> roles = _roleRepository.GetRoles(site.SiteId, true).ToList();
|
||||
if (!roles.Where(item => item.Name == Constants.AllUsersRole).Any())
|
||||
{
|
||||
RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true });
|
||||
_roleRepository.AddRole(new Role { SiteId = null, Name = Constants.AllUsersRole, Description = "All Users", IsAutoAssigned = false, IsSystem = true });
|
||||
}
|
||||
if (!roles.Where(item => item.Name == Constants.HostRole).Any())
|
||||
{
|
||||
RoleRepository.AddRole(new Role { SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true });
|
||||
_roleRepository.AddRole(new Role { SiteId = null, Name = Constants.HostRole, Description = "Application Administrators", IsAutoAssigned = false, IsSystem = true });
|
||||
}
|
||||
|
||||
RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true });
|
||||
RoleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true });
|
||||
_roleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.RegisteredRole, Description = "Registered Users", IsAutoAssigned = true, IsSystem = true });
|
||||
_roleRepository.AddRole(new Role { SiteId = site.SiteId, Name = Constants.AdminRole, Description = "Site Administrators", IsAutoAssigned = false, IsSystem = true });
|
||||
|
||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false });
|
||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false });
|
||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
ProfileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
_profileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "FirstName", Title = "First Name", Description = "Your First Or Given Name", Category = "Name", ViewOrder = 1, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false });
|
||||
_profileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "LastName", Title = "Last Name", Description = "Your Last Or Family Name", Category = "Name", ViewOrder = 2, MaxLength = 50, DefaultValue = "", IsRequired = true, IsPrivate = false });
|
||||
_profileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Street", Title = "Street", Description = "Street Or Building Address", Category = "Address", ViewOrder = 3, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
_profileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "City", Title = "City", Description = "City", Category = "Address", ViewOrder = 4, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
_profileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Region", Title = "Region", Description = "State Or Province", Category = "Address", ViewOrder = 5, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
_profileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Country", Title = "Country", Description = "Country", Category = "Address", ViewOrder = 6, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
_profileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "PostalCode", Title = "Postal Code", Description = "Postal Code Or Zip Code", Category = "Address", ViewOrder = 7, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
_profileRepository.AddProfile(new Profile { SiteId = site.SiteId, Name = "Phone", Title = "Phone Number", Description = "Phone Number", Category = "Contact", ViewOrder = 8, MaxLength = 50, DefaultValue = "", IsRequired = false, IsPrivate = false });
|
||||
|
||||
Folder folder = FolderRepository.AddFolder(new Folder { SiteId = site.SiteId, ParentId = null, Name = "Root", Path = "", Order = 1, IsSystem = true, Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]" });
|
||||
FolderRepository.AddFolder(new Folder { SiteId = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = "Users\\", Order = 1, IsSystem = true, Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]" });
|
||||
Folder folder = _folderRepository.AddFolder(new Folder { SiteId = site.SiteId, ParentId = null, Name = "Root", Path = "", Order = 1, IsSystem = true, Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"All Users\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]" });
|
||||
_folderRepository.AddFolder(new Folder { SiteId = site.SiteId, ParentId = folder.FolderId, Name = "Users", Path = "Users\\", Order = 1, IsSystem = true, Permissions = "[{\"PermissionName\":\"Browse\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"View\",\"Permissions\":\"Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]" });
|
||||
if (site.Name == "Default Site")
|
||||
{
|
||||
File file = FileRepository.AddFile(new File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192, ImageHeight = 80, ImageWidth = 250 });
|
||||
File file = _fileRepository.AddFile(new File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192, ImageHeight = 80, ImageWidth = 250 });
|
||||
site.LogoFileId = file.FileId;
|
||||
UpdateSite(site);
|
||||
}
|
||||
|
||||
List<ModuleDefinition> moduledefinitions = ModuleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList();
|
||||
foreach (PageTemplate pagetemplate in SiteTemplate)
|
||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitionRepository.GetModuleDefinitions(site.SiteId).ToList();
|
||||
foreach (PageTemplate pagetemplate in _siteTemplate)
|
||||
{
|
||||
int? parentid = null;
|
||||
if (pagetemplate.Parent != "")
|
||||
{
|
||||
List<Page> pages = PageRepository.GetPages(site.SiteId).ToList();
|
||||
List<Page> pages = _pageRepository.GetPages(site.SiteId).ToList();
|
||||
Page parent = pages.Where(item => item.Name == pagetemplate.Parent).FirstOrDefault();
|
||||
parentid = parent.PageId;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ namespace Oqtane.Repository
|
|||
IsPersonalizable = pagetemplate.IsPersonalizable,
|
||||
UserId = null
|
||||
};
|
||||
page = PageRepository.AddPage(page);
|
||||
page = _pageRepository.AddPage(page);
|
||||
|
||||
foreach(PageTemplateModule pagetemplatemodule in pagetemplate.PageTemplateModules)
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ namespace Oqtane.Repository
|
|||
ModuleDefinitionName = pagetemplatemodule.ModuleDefinitionName,
|
||||
Permissions = pagetemplatemodule.ModulePermissions,
|
||||
};
|
||||
module = ModuleRepository.AddModule(module);
|
||||
module = _moduleRepository.AddModule(module);
|
||||
|
||||
if (pagetemplatemodule.Content != "" && moduledefinition.ServerAssemblyName != "")
|
||||
{
|
||||
|
@ -246,7 +246,7 @@ namespace Oqtane.Repository
|
|||
.Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault();
|
||||
if (moduletype != null)
|
||||
{
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype);
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
||||
((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version);
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ namespace Oqtane.Repository
|
|||
Order = 1,
|
||||
ContainerType = ""
|
||||
};
|
||||
PageModuleRepository.AddPageModule(pagemodule);
|
||||
_pageModuleRepository.AddPageModule(pagemodule);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class TenantRepository : ITenantRepository
|
||||
{
|
||||
private MasterDBContext db;
|
||||
private MasterDBContext _db;
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
public TenantRepository(MasterDBContext context, IMemoryCache cache)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
|
@ -24,36 +24,36 @@ namespace Oqtane.Repository
|
|||
return _cache.GetOrCreate("tenants", entry =>
|
||||
{
|
||||
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
||||
return db.Tenant.ToList();
|
||||
return _db.Tenant.ToList();
|
||||
});
|
||||
}
|
||||
|
||||
public Tenant AddTenant(Tenant Tenant)
|
||||
{
|
||||
db.Tenant.Add(Tenant);
|
||||
db.SaveChanges();
|
||||
_db.Tenant.Add(Tenant);
|
||||
_db.SaveChanges();
|
||||
_cache.Remove("tenants");
|
||||
return Tenant;
|
||||
}
|
||||
|
||||
public Tenant UpdateTenant(Tenant Tenant)
|
||||
{
|
||||
db.Entry(Tenant).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(Tenant).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
_cache.Remove("tenants");
|
||||
return Tenant;
|
||||
}
|
||||
|
||||
public Tenant GetTenant(int TenantId)
|
||||
{
|
||||
return db.Tenant.Find(TenantId);
|
||||
return _db.Tenant.Find(TenantId);
|
||||
}
|
||||
|
||||
public void DeleteTenant(int TenantId)
|
||||
{
|
||||
Tenant tenant = db.Tenant.Find(TenantId);
|
||||
db.Tenant.Remove(tenant);
|
||||
db.SaveChanges();
|
||||
Tenant tenant = _db.Tenant.Find(TenantId);
|
||||
_db.Tenant.Remove(tenant);
|
||||
_db.SaveChanges();
|
||||
_cache.Remove("tenants");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class TenantResolver : ITenantResolver
|
||||
{
|
||||
private readonly Alias alias = null;
|
||||
private readonly Tenant tenant = null;
|
||||
private readonly Alias _alias = null;
|
||||
private readonly Tenant _tenant = null;
|
||||
|
||||
public TenantResolver(IHttpContextAccessor Accessor, IAliasRepository Aliases, ITenantRepository Tenants, SiteState SiteState)
|
||||
{
|
||||
|
@ -56,27 +56,27 @@ namespace Oqtane.Repository
|
|||
|
||||
if (aliasid != -1)
|
||||
{
|
||||
alias = aliases.Where(item => item.AliasId == aliasid).FirstOrDefault();
|
||||
_alias = aliases.Where(item => item.AliasId == aliasid).FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
alias = aliases.Where(item => item.Name == aliasname).FirstOrDefault();
|
||||
_alias = aliases.Where(item => item.Name == aliasname).FirstOrDefault();
|
||||
}
|
||||
if (alias != null)
|
||||
if (_alias != null)
|
||||
{
|
||||
tenant = tenants.Where(item => item.TenantId == alias.TenantId).FirstOrDefault();
|
||||
_tenant = tenants.Where(item => item.TenantId == _alias.TenantId).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Alias GetAlias()
|
||||
{
|
||||
return alias;
|
||||
return _alias;
|
||||
}
|
||||
|
||||
public Tenant GetTenant()
|
||||
{
|
||||
return tenant;
|
||||
return _tenant;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,47 +7,47 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class UserRepository : IUserRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private TenantDBContext _db;
|
||||
|
||||
public UserRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<User> GetUsers()
|
||||
{
|
||||
return db.User;
|
||||
return _db.User;
|
||||
}
|
||||
|
||||
public User AddUser(User user)
|
||||
{
|
||||
db.User.Add(user);
|
||||
db.SaveChanges();
|
||||
_db.User.Add(user);
|
||||
_db.SaveChanges();
|
||||
return user;
|
||||
}
|
||||
|
||||
public User UpdateUser(User user)
|
||||
{
|
||||
db.Entry(user).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(user).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return user;
|
||||
}
|
||||
|
||||
public User GetUser(int userId)
|
||||
{
|
||||
return db.User.Find(userId);
|
||||
return _db.User.Find(userId);
|
||||
}
|
||||
|
||||
public User GetUser(string Username)
|
||||
{
|
||||
return db.User.Where(item => item.Username == Username).FirstOrDefault();
|
||||
return _db.User.Where(item => item.Username == Username).FirstOrDefault();
|
||||
}
|
||||
|
||||
public void DeleteUser(int userId)
|
||||
{
|
||||
User user = db.User.Find(userId);
|
||||
db.User.Remove(user);
|
||||
db.SaveChanges();
|
||||
User user = _db.User.Find(userId);
|
||||
_db.User.Remove(user);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,16 @@ namespace Oqtane.Repository
|
|||
{
|
||||
public class UserRoleRepository : IUserRoleRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private TenantDBContext _db;
|
||||
|
||||
public UserRoleRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<UserRole> GetUserRoles(int SiteId)
|
||||
{
|
||||
return db.UserRole
|
||||
return _db.UserRole
|
||||
.Include(item => item.Role) // eager load roles
|
||||
.Include(item => item.User) // eager load users
|
||||
.Where(item => item.Role.SiteId == SiteId || item.Role.SiteId == null);
|
||||
|
@ -24,7 +24,7 @@ namespace Oqtane.Repository
|
|||
|
||||
public IEnumerable<UserRole> GetUserRoles(int UserId, int SiteId)
|
||||
{
|
||||
return db.UserRole.Where(item => item.UserId == UserId)
|
||||
return _db.UserRole.Where(item => item.UserId == UserId)
|
||||
.Include(item => item.Role) // eager load roles
|
||||
.Include(item => item.User) // eager load users
|
||||
.Where(item => item.Role.SiteId == SiteId || item.Role.SiteId == null);
|
||||
|
@ -32,21 +32,21 @@ namespace Oqtane.Repository
|
|||
|
||||
public UserRole AddUserRole(UserRole UserRole)
|
||||
{
|
||||
db.UserRole.Add(UserRole);
|
||||
db.SaveChanges();
|
||||
_db.UserRole.Add(UserRole);
|
||||
_db.SaveChanges();
|
||||
return UserRole;
|
||||
}
|
||||
|
||||
public UserRole UpdateUserRole(UserRole UserRole)
|
||||
{
|
||||
db.Entry(UserRole).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
_db.Entry(UserRole).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return UserRole;
|
||||
}
|
||||
|
||||
public UserRole GetUserRole(int UserRoleId)
|
||||
{
|
||||
return db.UserRole
|
||||
return _db.UserRole
|
||||
.Include(item => item.Role) // eager load roles
|
||||
.Include(item => item.User) // eager load users
|
||||
.SingleOrDefault(item => item.UserRoleId == UserRoleId);
|
||||
|
@ -54,9 +54,9 @@ namespace Oqtane.Repository
|
|||
|
||||
public void DeleteUserRole(int UserRoleId)
|
||||
{
|
||||
UserRole UserRole = db.UserRole.Find(UserRoleId);
|
||||
db.UserRole.Remove(UserRole);
|
||||
db.SaveChanges();
|
||||
UserRole UserRole = _db.UserRole.Find(UserRoleId);
|
||||
_db.UserRole.Remove(UserRole);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,42 +12,42 @@ namespace Oqtane.Security
|
|||
{
|
||||
public class ClaimsPrincipalFactory<TUser> : UserClaimsPrincipalFactory<TUser> where TUser : IdentityUser
|
||||
{
|
||||
private readonly IdentityOptions options;
|
||||
private readonly ITenantResolver Tenants;
|
||||
private readonly IUserRepository Users;
|
||||
private readonly IUserRoleRepository UserRoles;
|
||||
private readonly IdentityOptions _options;
|
||||
private readonly ITenantResolver _tenants;
|
||||
private readonly IUserRepository _users;
|
||||
private readonly IUserRoleRepository _userRoles;
|
||||
|
||||
public ClaimsPrincipalFactory(UserManager<TUser> userManager, IOptions<IdentityOptions> optionsAccessor, ITenantResolver tenants, IUserRepository users, IUserRoleRepository userroles) : base(userManager, optionsAccessor)
|
||||
{
|
||||
options = optionsAccessor.Value;
|
||||
Tenants = tenants;
|
||||
Users = users;
|
||||
UserRoles = userroles;
|
||||
_options = optionsAccessor.Value;
|
||||
_tenants = tenants;
|
||||
_users = users;
|
||||
_userRoles = userroles;
|
||||
}
|
||||
|
||||
protected override async Task<ClaimsIdentity> GenerateClaimsAsync(TUser identityuser)
|
||||
{
|
||||
var id = await base.GenerateClaimsAsync(identityuser);
|
||||
|
||||
User user = Users.GetUser(identityuser.UserName);
|
||||
User user = _users.GetUser(identityuser.UserName);
|
||||
if (user != null)
|
||||
{
|
||||
id.AddClaim(new Claim(ClaimTypes.PrimarySid, user.UserId.ToString()));
|
||||
Alias alias = Tenants.GetAlias();
|
||||
List<UserRole> userroles = UserRoles.GetUserRoles(user.UserId, alias.SiteId).ToList();
|
||||
Alias alias = _tenants.GetAlias();
|
||||
List<UserRole> userroles = _userRoles.GetUserRoles(user.UserId, alias.SiteId).ToList();
|
||||
foreach (UserRole userrole in userroles)
|
||||
{
|
||||
id.AddClaim(new Claim(options.ClaimsIdentity.RoleClaimType, userrole.Role.Name));
|
||||
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, userrole.Role.Name));
|
||||
// host users are members of every site
|
||||
if (userrole.Role.Name == Constants.HostRole)
|
||||
{
|
||||
if (userroles.Where(item => item.Role.Name == Constants.RegisteredRole).FirstOrDefault() == null)
|
||||
{
|
||||
id.AddClaim(new Claim(options.ClaimsIdentity.RoleClaimType, Constants.RegisteredRole));
|
||||
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, Constants.RegisteredRole));
|
||||
}
|
||||
if (userroles.Where(item => item.Role.Name == Constants.AdminRole).FirstOrDefault() == null)
|
||||
{
|
||||
id.AddClaim(new Claim(options.ClaimsIdentity.RoleClaimType, Constants.AdminRole));
|
||||
id.AddClaim(new Claim(_options.ClaimsIdentity.RoleClaimType, Constants.AdminRole));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,31 +8,31 @@ namespace Oqtane.Security
|
|||
{
|
||||
public class PermissionHandler : AuthorizationHandler<PermissionRequirement>
|
||||
{
|
||||
private readonly IHttpContextAccessor HttpContextAccessor;
|
||||
private readonly IUserPermissions UserPermissions;
|
||||
private readonly ILogManager logger;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public PermissionHandler(IHttpContextAccessor HttpContextAccessor, IUserPermissions UserPermissions, ILogManager logger)
|
||||
{
|
||||
this.HttpContextAccessor = HttpContextAccessor;
|
||||
this.UserPermissions = UserPermissions;
|
||||
this.logger = logger;
|
||||
this._httpContextAccessor = HttpContextAccessor;
|
||||
this._userPermissions = UserPermissions;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement)
|
||||
{
|
||||
// permission is scoped based on EntityId which must be passed as a querystring parameter
|
||||
var ctx = HttpContextAccessor.HttpContext;
|
||||
var ctx = _httpContextAccessor.HttpContext;
|
||||
if (ctx != null && ctx.Request.Query.ContainsKey("entityid"))
|
||||
{
|
||||
int EntityId = int.Parse(ctx.Request.Query["entityid"]);
|
||||
if (UserPermissions.IsAuthorized(context.User, requirement.EntityName, EntityId, requirement.PermissionName))
|
||||
if (_userPermissions.IsAuthorized(context.User, requirement.EntityName, EntityId, requirement.PermissionName))
|
||||
{
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Log(LogLevel.Error, this, LogFunction.Security, "User {User} Does Not Have {PermissionName} Permission For {EntityName}:{EntityId}", context.User, requirement.PermissionName, requirement.EntityName, EntityId);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "User {User} Does Not Have {PermissionName} Permission For {EntityName}:{EntityId}", context.User, requirement.PermissionName, requirement.EntityName, EntityId);
|
||||
}
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
|
|
|
@ -8,18 +8,18 @@ namespace Oqtane.Security
|
|||
{
|
||||
public class UserPermissions : IUserPermissions
|
||||
{
|
||||
private readonly IPermissionRepository Permissions;
|
||||
private readonly IHttpContextAccessor Accessor;
|
||||
private readonly IPermissionRepository _permissions;
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
|
||||
public UserPermissions(IPermissionRepository Permissions, IHttpContextAccessor Accessor)
|
||||
{
|
||||
this.Permissions = Permissions;
|
||||
this.Accessor = Accessor;
|
||||
this._permissions = Permissions;
|
||||
this._accessor = Accessor;
|
||||
}
|
||||
|
||||
public bool IsAuthorized(ClaimsPrincipal User, string EntityName, int EntityId, string PermissionName)
|
||||
{
|
||||
return IsAuthorized(User, PermissionName, Permissions.EncodePermissions(EntityId, Permissions.GetPermissions(EntityName, EntityId, PermissionName).ToList()));
|
||||
return IsAuthorized(User, PermissionName, _permissions.EncodePermissions(EntityId, _permissions.GetPermissions(EntityName, EntityId, PermissionName).ToList()));
|
||||
}
|
||||
|
||||
public bool IsAuthorized(ClaimsPrincipal User, string PermissionName, string Permissions)
|
||||
|
@ -56,7 +56,7 @@ namespace Oqtane.Security
|
|||
|
||||
public User GetUser()
|
||||
{
|
||||
return GetUser(Accessor.HttpContext.User);
|
||||
return GetUser(_accessor.HttpContext.User);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user