Merge pull request #4532 from sbwalker/dev
ensure form name is unique in ActionDialog
This commit is contained in:
commit
c0a0deea78
|
@ -51,7 +51,7 @@ else
|
||||||
<div class="modal" tabindex="-1" role="dialog">
|
<div class="modal" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<form class="app-form-inline" method="post" @formname="@($"ActionDialogCloseForm{Id}")" @onsubmit="DisplayModal" data-enhance>
|
<form class="app-form-inline" method="post" @formname="@($"ActionDialogCloseForm:{ModuleState.PageModuleId}:{Id}")" @onsubmit="DisplayModal" data-enhance>
|
||||||
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">@Header</h5>
|
<h5 class="modal-title">@Header</h5>
|
||||||
|
@ -64,12 +64,12 @@ else
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
@if (!string.IsNullOrEmpty(Action))
|
@if (!string.IsNullOrEmpty(Action))
|
||||||
{
|
{
|
||||||
<form method="post" @formname="@($"ActionDialogConfirmForm{Id}")" @onsubmit="Confirm" data-enhance>
|
<form method="post" @formname="@($"ActionDialogConfirmForm:{ModuleState.PageModuleId}:{Id}")" @onsubmit="Confirm" data-enhance>
|
||||||
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
||||||
<button type="submit" class="@Class">@((MarkupString)_iconSpan) @Text</button>
|
<button type="submit" class="@Class">@((MarkupString)_iconSpan) @Text</button>
|
||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
<form method="post" @formname="@($"ActionDialogCancelForm{Id}")" @onsubmit="DisplayModal" data-enhance>
|
<form method="post" @formname="@($"ActionDialogCancelForm:{ModuleState.PageModuleId}:{Id}")" @onsubmit="DisplayModal" data-enhance>
|
||||||
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
||||||
<button type="submit" class="btn btn-secondary">@SharedLocalizer["Cancel"]</button>
|
<button type="submit" class="btn btn-secondary">@SharedLocalizer["Cancel"]</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -87,7 +87,7 @@ else
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<form method="post" class="app-form-inline" @formname="@($"ActionDialogActionForm{Id}")" @onsubmit="DisplayModal" data-enhance>
|
<form method="post" class="app-form-inline" @formname="@($"ActionDialogActionForm:{ModuleState.PageModuleId}:{Id}")" @onsubmit="DisplayModal" data-enhance>
|
||||||
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
||||||
<button type="submit" class="@Class">@((MarkupString)_openIconSpan) @_openText</button>
|
<button type="submit" class="@Class">@((MarkupString)_openIconSpan) @_openText</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -6,15 +6,6 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
public interface ISiteRepository
|
public interface ISiteRepository
|
||||||
{
|
{
|
||||||
// asynchronous methods
|
|
||||||
Task<IEnumerable<Site>> GetSitesAsync();
|
|
||||||
Task<Site> AddSiteAsync(Site site);
|
|
||||||
Task<Site> UpdateSiteAsync(Site site);
|
|
||||||
Task<Site> GetSiteAsync(int siteId);
|
|
||||||
Task<Site> GetSiteAsync(int siteId, bool tracking);
|
|
||||||
Task DeleteSiteAsync(int siteId);
|
|
||||||
|
|
||||||
// synchronous methods
|
|
||||||
IEnumerable<Site> GetSites();
|
IEnumerable<Site> GetSites();
|
||||||
Site AddSite(Site site);
|
Site AddSite(Site site);
|
||||||
Site UpdateSite(Site site);
|
Site UpdateSite(Site site);
|
||||||
|
|
|
@ -2,7 +2,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
@ -51,58 +50,6 @@ namespace Oqtane.Repository
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
// asynchronous methods
|
|
||||||
public async Task<IEnumerable<Site>> GetSitesAsync()
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
return await db.Site.OrderBy(item => item.Name).ToListAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Site> AddSiteAsync(Site site)
|
|
||||||
{
|
|
||||||
site.SiteGuid = Guid.NewGuid().ToString();
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
db.Site.Add(site);
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
CreateSite(site);
|
|
||||||
return site;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Site> UpdateSiteAsync(Site site)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
db.Entry(site).State = EntityState.Modified;
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
return site;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Site> GetSiteAsync(int siteId)
|
|
||||||
{
|
|
||||||
return await GetSiteAsync(siteId, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Site> GetSiteAsync(int siteId, bool tracking)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
if (tracking)
|
|
||||||
{
|
|
||||||
return await db.Site.FindAsync(siteId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return await db.Site.AsNoTracking().FirstOrDefaultAsync(item => item.SiteId == siteId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task DeleteSiteAsync(int siteId)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
var site = db.Site.Find(siteId);
|
|
||||||
db.Site.Remove(site);
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
// synchronous methods
|
|
||||||
public IEnumerable<Site> GetSites()
|
public IEnumerable<Site> GetSites()
|
||||||
{
|
{
|
||||||
using var db = _factory.CreateDbContext();
|
using var db = _factory.CreateDbContext();
|
||||||
|
|
|
@ -50,23 +50,23 @@ namespace Oqtane.Services
|
||||||
_accessor = accessor;
|
_accessor = accessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Site>> GetSitesAsync()
|
public Task<List<Site>> GetSitesAsync()
|
||||||
{
|
{
|
||||||
List<Site> sites = new List<Site>();
|
List<Site> sites = new List<Site>();
|
||||||
if (_accessor.HttpContext.User.IsInRole(RoleNames.Host))
|
if (_accessor.HttpContext.User.IsInRole(RoleNames.Host))
|
||||||
{
|
{
|
||||||
sites = (await _sites.GetSitesAsync()).ToList();
|
sites = _sites.GetSites().ToList();
|
||||||
}
|
}
|
||||||
return sites;
|
return Task.FromResult(sites);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Site> GetSiteAsync(int siteId)
|
public Task<Site> GetSiteAsync(int siteId)
|
||||||
{
|
{
|
||||||
var alias = _tenantManager.GetAlias();
|
var alias = _tenantManager.GetAlias();
|
||||||
var site = await _cache.GetOrCreateAsync($"site:{alias.SiteKey}", async entry =>
|
var site = _cache.GetOrCreate($"site:{alias.SiteKey}", entry =>
|
||||||
{
|
{
|
||||||
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
||||||
return await GetSite(siteId);
|
return GetSite(siteId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// trim pages based on user permissions
|
// trim pages based on user permissions
|
||||||
|
@ -83,13 +83,13 @@ namespace Oqtane.Services
|
||||||
site = site.Clone(site);
|
site = site.Clone(site);
|
||||||
site.Pages = pages;
|
site.Pages = pages;
|
||||||
|
|
||||||
return site;
|
return Task.FromResult(site);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Site> GetSite(int siteid)
|
private Site GetSite(int siteid)
|
||||||
{
|
{
|
||||||
var alias = _tenantManager.GetAlias();
|
var alias = _tenantManager.GetAlias();
|
||||||
var site = await _sites.GetSiteAsync(siteid);
|
var site = _sites.GetSite(siteid);
|
||||||
if (site != null && site.SiteId == alias.SiteId)
|
if (site != null && site.SiteId == alias.SiteId)
|
||||||
{
|
{
|
||||||
// site settings
|
// site settings
|
||||||
|
@ -116,7 +116,7 @@ namespace Oqtane.Services
|
||||||
site.Pages = GetPagesHierarchy(site.Pages);
|
site.Pages = GetPagesHierarchy(site.Pages);
|
||||||
|
|
||||||
// framework modules
|
// framework modules
|
||||||
var modules = await GetModulesAsync(site.SiteId);
|
var modules = GetModules(site.SiteId);
|
||||||
site.Settings.Add(Constants.AdminDashboardModule, modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.AdminDashboardModule).ModuleId.ToString());
|
site.Settings.Add(Constants.AdminDashboardModule, modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.AdminDashboardModule).ModuleId.ToString());
|
||||||
site.Settings.Add(Constants.PageManagementModule, modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.PageManagementModule).ModuleId.ToString());
|
site.Settings.Add(Constants.PageManagementModule, modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.PageManagementModule).ModuleId.ToString());
|
||||||
|
|
||||||
|
@ -179,11 +179,11 @@ namespace Oqtane.Services
|
||||||
return hierarchy;
|
return hierarchy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Site> AddSiteAsync(Site site)
|
public Task<Site> AddSiteAsync(Site site)
|
||||||
{
|
{
|
||||||
if (_accessor.HttpContext.User.IsInRole(RoleNames.Host))
|
if (_accessor.HttpContext.User.IsInRole(RoleNames.Host))
|
||||||
{
|
{
|
||||||
site = await _sites.AddSiteAsync(site);
|
site = _sites.AddSite(site);
|
||||||
_syncManager.AddSyncEvent(_tenantManager.GetAlias(), EntityNames.Site, site.SiteId, SyncEventActions.Create);
|
_syncManager.AddSyncEvent(_tenantManager.GetAlias(), EntityNames.Site, site.SiteId, SyncEventActions.Create);
|
||||||
_logger.Log(site.SiteId, LogLevel.Information, this, LogFunction.Create, "Site Added {Site}", site);
|
_logger.Log(site.SiteId, LogLevel.Information, this, LogFunction.Create, "Site Added {Site}", site);
|
||||||
}
|
}
|
||||||
|
@ -191,18 +191,18 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
site = null;
|
site = null;
|
||||||
}
|
}
|
||||||
return site;
|
return Task.FromResult(site);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Site> UpdateSiteAsync(Site site)
|
public Task<Site> UpdateSiteAsync(Site site)
|
||||||
{
|
{
|
||||||
if (_accessor.HttpContext.User.IsInRole(RoleNames.Admin))
|
if (_accessor.HttpContext.User.IsInRole(RoleNames.Admin))
|
||||||
{
|
{
|
||||||
var alias = _tenantManager.GetAlias();
|
var alias = _tenantManager.GetAlias();
|
||||||
var current = await _sites.GetSiteAsync(site.SiteId, false);
|
var current = _sites.GetSite(site.SiteId, false);
|
||||||
if (site.SiteId == alias.SiteId && site.TenantId == alias.TenantId && current != null)
|
if (site.SiteId == alias.SiteId && site.TenantId == alias.TenantId && current != null)
|
||||||
{
|
{
|
||||||
site = await _sites.UpdateSiteAsync(site);
|
site = _sites.UpdateSite(site);
|
||||||
_syncManager.AddSyncEvent(alias, EntityNames.Site, site.SiteId, SyncEventActions.Update);
|
_syncManager.AddSyncEvent(alias, EntityNames.Site, site.SiteId, SyncEventActions.Update);
|
||||||
string action = SyncEventActions.Refresh;
|
string action = SyncEventActions.Refresh;
|
||||||
if (current.RenderMode != site.RenderMode || current.Runtime != site.Runtime)
|
if (current.RenderMode != site.RenderMode || current.Runtime != site.Runtime)
|
||||||
|
@ -222,18 +222,18 @@ namespace Oqtane.Services
|
||||||
{
|
{
|
||||||
site = null;
|
site = null;
|
||||||
}
|
}
|
||||||
return site;
|
return Task.FromResult(site);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteSiteAsync(int siteId)
|
public Task DeleteSiteAsync(int siteId)
|
||||||
{
|
{
|
||||||
if (_accessor.HttpContext.User.IsInRole(RoleNames.Host))
|
if (_accessor.HttpContext.User.IsInRole(RoleNames.Host))
|
||||||
{
|
{
|
||||||
var alias = _tenantManager.GetAlias();
|
var alias = _tenantManager.GetAlias();
|
||||||
var site = await _sites.GetSiteAsync(siteId);
|
var site = _sites.GetSite(siteId);
|
||||||
if (site != null && site.SiteId == alias.SiteId)
|
if (site != null && site.SiteId == alias.SiteId)
|
||||||
{
|
{
|
||||||
await _sites.DeleteSiteAsync(siteId);
|
_sites.DeleteSite(siteId);
|
||||||
_syncManager.AddSyncEvent(alias, EntityNames.Site, site.SiteId, SyncEventActions.Delete);
|
_syncManager.AddSyncEvent(alias, EntityNames.Site, site.SiteId, SyncEventActions.Delete);
|
||||||
_logger.Log(siteId, LogLevel.Information, this, LogFunction.Delete, "Site Deleted {SiteId}", siteId);
|
_logger.Log(siteId, LogLevel.Information, this, LogFunction.Delete, "Site Deleted {SiteId}", siteId);
|
||||||
}
|
}
|
||||||
|
@ -242,15 +242,16 @@ namespace Oqtane.Services
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Site Delete Attempt {SiteId}", siteId);
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Site Delete Attempt {SiteId}", siteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Module>> GetModulesAsync(int siteId, int pageId)
|
public Task<List<Module>> GetModulesAsync(int siteId, int pageId)
|
||||||
{
|
{
|
||||||
var alias = _tenantManager.GetAlias();
|
var alias = _tenantManager.GetAlias();
|
||||||
var sitemodules = await _cache.GetOrCreateAsync($"modules:{alias.SiteKey}", async entry =>
|
var sitemodules = _cache.GetOrCreate($"modules:{alias.SiteKey}", entry =>
|
||||||
{
|
{
|
||||||
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
||||||
return await GetModulesAsync(siteId);
|
return GetModules(siteId);
|
||||||
});
|
});
|
||||||
|
|
||||||
var modules = new List<Module>();
|
var modules = new List<Module>();
|
||||||
|
@ -261,23 +262,21 @@ namespace Oqtane.Services
|
||||||
modules.Add(module);
|
modules.Add(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return modules;
|
return Task.FromResult(modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Module>> GetModulesAsync(int siteId)
|
private List<Module> GetModules(int siteId)
|
||||||
{
|
{
|
||||||
var alias = _tenantManager.GetAlias();
|
var alias = _tenantManager.GetAlias();
|
||||||
return await _cache.GetOrCreateAsync($"modules:{alias.SiteKey}", async entry =>
|
return _cache.GetOrCreate($"modules:{alias.SiteKey}", entry =>
|
||||||
{
|
{
|
||||||
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
entry.SlidingExpiration = TimeSpan.FromMinutes(30);
|
||||||
return await GetModules(siteId);
|
return GetPageModules(siteId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<Module>> GetModules(int siteId)
|
private List<Module> GetPageModules(int siteId)
|
||||||
{
|
{
|
||||||
await Task.Yield(); // force method to async
|
|
||||||
|
|
||||||
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(siteId).ToList();
|
List<ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(siteId).ToList();
|
||||||
var settings = _settings.GetSettings(EntityNames.Module).ToList();
|
var settings = _settings.GetSettings(EntityNames.Module).ToList();
|
||||||
var modules = new List<Module>();
|
var modules = new List<Module>();
|
||||||
|
|
|
@ -11,12 +11,5 @@ namespace [Owner].Module.[Module].Repository
|
||||||
Models.[Module] Add[Module](Models.[Module] [Module]);
|
Models.[Module] Add[Module](Models.[Module] [Module]);
|
||||||
Models.[Module] Update[Module](Models.[Module] [Module]);
|
Models.[Module] Update[Module](Models.[Module] [Module]);
|
||||||
void Delete[Module](int [Module]Id);
|
void Delete[Module](int [Module]Id);
|
||||||
|
|
||||||
Task<IEnumerable<Models.[Module]>> Get[Module]sAsync(int ModuleId);
|
|
||||||
Task<Models.[Module]> Get[Module]Async(int [Module]Id);
|
|
||||||
Task<Models.[Module]> Get[Module]Async(int [Module]Id, bool tracking);
|
|
||||||
Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module]);
|
|
||||||
Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module]);
|
|
||||||
Task Delete[Module]Async(int [Module]Id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace [Owner].Module.[Module].Repository
|
namespace [Owner].Module.[Module].Repository
|
||||||
{
|
{
|
||||||
|
@ -62,54 +61,5 @@ namespace [Owner].Module.[Module].Repository
|
||||||
db.[Module].Remove([Module]);
|
db.[Module].Remove([Module]);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<IEnumerable<Models.[Module]>> Get[Module]sAsync(int ModuleId)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
return await db.[Module].Where(item => item.ModuleId == ModuleId).ToListAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Models.[Module]> Get[Module]Async(int [Module]Id)
|
|
||||||
{
|
|
||||||
return await Get[Module]Async([Module]Id, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Models.[Module]> Get[Module]Async(int [Module]Id, bool tracking)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
if (tracking)
|
|
||||||
{
|
|
||||||
return await db.[Module].FindAsync([Module]Id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return await db.[Module].AsNoTracking().FirstOrDefaultAsync(item => item.[Module]Id == [Module]Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module])
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
db.[Module].Add([Module]);
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
return [Module];
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module])
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
db.Entry([Module]).State = EntityState.Modified;
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
return [Module];
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Delete[Module]Async(int [Module]Id)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
Models.[Module] [Module] = db.[Module].Find([Module]Id);
|
|
||||||
db.[Module].Remove([Module]);
|
|
||||||
await db.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,11 @@ namespace [Owner].Module.[Module].Services
|
||||||
_alias = tenantManager.GetAlias();
|
_alias = tenantManager.GetAlias();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Models.[Module]>> Get[Module]sAsync(int ModuleId)
|
public Task<List<Models.[Module]>> Get[Module]sAsync(int ModuleId)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||||
{
|
{
|
||||||
return (await _[Module]Repository.Get[Module]sAsync(ModuleId)).ToList();
|
return Task.FromResult(_[Module]Repository.Get[Module]s(ModuleId).ToList());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -42,11 +42,11 @@ namespace [Owner].Module.[Module].Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Models.[Module]> Get[Module]Async(int [Module]Id, int ModuleId)
|
public Task<Models.[Module]> Get[Module]Async(int [Module]Id, int ModuleId)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||||
{
|
{
|
||||||
return await _[Module]Repository.Get[Module]Async([Module]Id);
|
return Task.FromResult(_[Module]Repository.Get[Module]([Module]Id));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -55,11 +55,11 @@ namespace [Owner].Module.[Module].Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module])
|
public Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module])
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, [Module].ModuleId, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, [Module].ModuleId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
[Module] = await _[Module]Repository.Add[Module]Async([Module]);
|
[Module] = _[Module]Repository.Add[Module]([Module]);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -67,14 +67,14 @@ namespace [Owner].Module.[Module].Services
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Add Attempt {[Module]}", [Module]);
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Add Attempt {[Module]}", [Module]);
|
||||||
[Module] = null;
|
[Module] = null;
|
||||||
}
|
}
|
||||||
return [Module];
|
return Task.FromResult([Module]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module])
|
public Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module])
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, [Module].ModuleId, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, [Module].ModuleId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
[Module] = await _[Module]Repository.Update[Module]Async([Module]);
|
[Module] = _[Module]Repository.Update[Module]([Module]);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -82,20 +82,21 @@ namespace [Owner].Module.[Module].Services
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Update Attempt {[Module]}", [Module]);
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Update Attempt {[Module]}", [Module]);
|
||||||
[Module] = null;
|
[Module] = null;
|
||||||
}
|
}
|
||||||
return [Module];
|
return Task.FromResult([Module]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Delete[Module]Async(int [Module]Id, int ModuleId)
|
public Task Delete[Module]Async(int [Module]Id, int ModuleId)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
await _[Module]Repository.Delete[Module]Async([Module]Id);
|
_[Module]Repository.Delete[Module]([Module]Id);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", [Module]Id);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", [Module]Id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Delete Attempt {[Module]Id} {ModuleId}", [Module]Id, ModuleId);
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized [Module] Delete Attempt {[Module]Id} {ModuleId}", [Module]Id, ModuleId);
|
||||||
}
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user