resolve #526 remove pluralization from module creation templates
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
@using Oqtane.Modules.Controls
|
||||
@using [Owner].[Module]s.Services
|
||||
@using [Owner].[Module]s.Models
|
||||
@using [Owner].[Module].Services
|
||||
@using [Owner].[Module].Models
|
||||
|
||||
@namespace [Owner].[Module]s
|
||||
@namespace [Owner].[Module]
|
||||
@inherits ModuleBase
|
||||
@inject I[Module]Service [Module]Service
|
||||
@inject NavigationManager NavigationManager
|
||||
@ -31,6 +31,8 @@
|
||||
|
||||
public override string Actions => "Add,Edit";
|
||||
|
||||
public override string Title => "Manage [Module]";
|
||||
|
||||
public override List<Resource> Resources => new List<Resource>()
|
||||
{
|
||||
new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
|
@ -1,7 +1,7 @@
|
||||
@using [Owner].[Module]s.Services
|
||||
@using [Owner].[Module]s.Models
|
||||
@using [Owner].[Module].Services
|
||||
@using [Owner].[Module].Models
|
||||
|
||||
@namespace [Owner].[Module]s
|
||||
@namespace [Owner].[Module]
|
||||
@inherits ModuleBase
|
||||
@inject I[Module]Service [Module]Service
|
||||
@inject NavigationManager NavigationManager
|
||||
@ -17,16 +17,16 @@ else
|
||||
<br />
|
||||
@if (@_[Module]s.Count != 0)
|
||||
{
|
||||
<Pager Items="@_[Module]s" Format="Grid">
|
||||
<Pager Items="@_[Module]s">
|
||||
<Header>
|
||||
<div class="col"><strong>[Module]s</strong></div>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th>Name</th>
|
||||
</Header>
|
||||
<Row>
|
||||
<div class="col">
|
||||
<ActionLink Action="Edit" Parameters="@($"id=" + context.[Module]Id.ToString())" />
|
||||
<ActionDialog Header="Delete [Module]" Message="@("Are You Sure You Wish To Delete The " + context.Name + " [Module]?")" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" />
|
||||
@context.Name
|
||||
</div>
|
||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.[Module]Id.ToString())" /></td>
|
||||
<td><ActionDialog Header="Delete [Module]" Message="@("Are You Sure You Wish To Delete The " + context.Name + " [Module]?")" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" /></td>
|
||||
<td>@context.Name</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace [Owner].[Module]s
|
||||
namespace [Owner].[Module]
|
||||
{
|
||||
public class ModuleInfo : IModule
|
||||
{
|
@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using [Owner].[Module].Models;
|
||||
|
||||
namespace [Owner].[Module].Services
|
||||
{
|
||||
public interface I[Module]Service
|
||||
{
|
||||
Task<List<Models.[Module]>> Get[Module]sAsync(int ModuleId);
|
||||
|
||||
Task<Models.[Module]> Get[Module]Async(int [Module]Id, int ModuleId);
|
||||
|
||||
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, int ModuleId);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
using [Owner].[Module].Models;
|
||||
|
||||
namespace [Owner].[Module].Services
|
||||
{
|
||||
public class [Module]Service : ServiceBase, I[Module]Service, IService
|
||||
{
|
||||
private readonly SiteState _siteState;
|
||||
|
||||
public [Module]Service(HttpClient http, SiteState siteState) : base(http)
|
||||
{
|
||||
_siteState = siteState;
|
||||
}
|
||||
|
||||
private string Apiurl => CreateApiUrl(_siteState.Alias, "[Module]");
|
||||
|
||||
public async Task<List<Models.[Module]>> Get[Module]sAsync(int ModuleId)
|
||||
{
|
||||
List<Models.[Module]> [Module]s = await GetJsonAsync<List<Models.[Module]>>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", ModuleId));
|
||||
return [Module]s.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<Models.[Module]> Get[Module]Async(int [Module]Id, int ModuleId)
|
||||
{
|
||||
return await GetJsonAsync<Models.[Module]>(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
|
||||
}
|
||||
|
||||
public async Task<Models.[Module]> Add[Module]Async(Models.[Module] [Module])
|
||||
{
|
||||
return await PostJsonAsync<Models.[Module]>(CreateAuthorizationPolicyUrl($"{Apiurl}", [Module].ModuleId), [Module]);
|
||||
}
|
||||
|
||||
public async Task<Models.[Module]> Update[Module]Async(Models.[Module] [Module])
|
||||
{
|
||||
return await PutJsonAsync<Models.[Module]>(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module].[Module]Id}", [Module].ModuleId), [Module]);
|
||||
}
|
||||
|
||||
public async Task Delete[Module]Async(int [Module]Id, int ModuleId)
|
||||
{
|
||||
await DeleteAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
@namespace [Owner].[Module]s
|
||||
@namespace [Owner].[Module]
|
||||
@inherits ModuleBase
|
||||
@inject ISettingService SettingService
|
||||
|
@ -1,19 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Services
|
||||
{
|
||||
public interface I[Module]Service
|
||||
{
|
||||
Task<List<[Module]>> Get[Module]sAsync(int ModuleId);
|
||||
|
||||
Task<[Module]> Get[Module]Async(int [Module]Id, int ModuleId);
|
||||
|
||||
Task<[Module]> Add[Module]Async([Module] [Module]);
|
||||
|
||||
Task<[Module]> Update[Module]Async([Module] [Module]);
|
||||
|
||||
Task Delete[Module]Async(int [Module]Id, int ModuleId);
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Services
|
||||
{
|
||||
public class [Module]Service : ServiceBase, I[Module]Service, IService
|
||||
{
|
||||
private readonly SiteState _siteState;
|
||||
|
||||
public [Module]Service(HttpClient http, SiteState siteState) : base(http)
|
||||
{
|
||||
_siteState = siteState;
|
||||
}
|
||||
|
||||
private string Apiurl => CreateApiUrl(_siteState.Alias, "[Module]");
|
||||
|
||||
public async Task<List<[Module]>> Get[Module]sAsync(int ModuleId)
|
||||
{
|
||||
List<[Module]> [Module]s = await GetJsonAsync<List<[Module]>>(CreateAuthPolicyUrl($"{Apiurl}?moduleid={ModuleId}", ModuleId));
|
||||
return [Module]s.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<[Module]> Get[Module]Async(int [Module]Id, int ModuleId)
|
||||
{
|
||||
return await GetJsonAsync<[Module]>(CreateAuthPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
|
||||
}
|
||||
|
||||
public async Task<[Module]> Add[Module]Async([Module] [Module])
|
||||
{
|
||||
return await PostJsonAsync<[Module]>(CreateAuthPolicyUrl($"{Apiurl}?entityid={[Module].ModuleId}", [Module].ModuleId), [Module]);
|
||||
}
|
||||
|
||||
public async Task<[Module]> Update[Module]Async([Module] [Module])
|
||||
{
|
||||
return await PutJsonAsync<[Module]>(CreateAuthPolicyUrl($"{Apiurl}/{[Module].[Module]Id}", [Module].ModuleId), [Module]);
|
||||
}
|
||||
|
||||
public async Task Delete[Module]Async(int [Module]Id, int ModuleId)
|
||||
{
|
||||
await DeleteAsync(CreateAuthPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
|
||||
}
|
||||
|
||||
private string CreateAuthPolicyUrl(string Url, int ModuleId)
|
||||
{
|
||||
if (Url.Contains("?"))
|
||||
{
|
||||
return Url + "&entityid=" + ModuleId.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Url + "?entityid=" + ModuleId.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,21 +5,21 @@ using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure;
|
||||
using [Owner].[Module]s.Models;
|
||||
using [Owner].[Module]s.Repository;
|
||||
using [Owner].[Module].Models;
|
||||
using [Owner].[Module].Repository;
|
||||
|
||||
namespace [Owner].[Module]s.Controllers
|
||||
namespace [Owner].[Module].Controllers
|
||||
{
|
||||
[Route("{alias}/api/[controller]")]
|
||||
public class [Module]Controller : Controller
|
||||
{
|
||||
private readonly I[Module]Repository _[Module]s;
|
||||
private readonly I[Module]Repository _[Module]Repository;
|
||||
private readonly ILogManager _logger;
|
||||
protected int _entityId = -1;
|
||||
|
||||
public [Module]Controller(I[Module]Repository [Module]s, ILogManager logger, IHttpContextAccessor accessor)
|
||||
public [Module]Controller(I[Module]Repository [Module]Repository, ILogManager logger, IHttpContextAccessor accessor)
|
||||
{
|
||||
_[Module]s = [Module]s;
|
||||
_[Module]Repository = [Module]Repository;
|
||||
_logger = logger;
|
||||
|
||||
if (accessor.HttpContext.Request.Query.ContainsKey("entityid"))
|
||||
@ -31,17 +31,17 @@ namespace [Owner].[Module]s.Controllers
|
||||
// GET: api/<controller>?moduleid=x
|
||||
[HttpGet]
|
||||
[Authorize(Policy = "ViewModule")]
|
||||
public IEnumerable<[Module]> Get(string moduleid)
|
||||
public IEnumerable<Models.[Module]> Get(string moduleid)
|
||||
{
|
||||
return _[Module]s.Get[Module]s(int.Parse(moduleid));
|
||||
return _[Module]Repository.Get[Module]s(int.Parse(moduleid));
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = "ViewModule")]
|
||||
public [Module] Get(int id)
|
||||
public Models.[Module] Get(int id)
|
||||
{
|
||||
[Module] [Module] = _[Module]s.Get[Module](id);
|
||||
Models.[Module] [Module] = _[Module]Repository.Get[Module](id);
|
||||
if ([Module] != null && [Module].ModuleId != _entityId)
|
||||
{
|
||||
[Module] = null;
|
||||
@ -52,11 +52,11 @@ namespace [Owner].[Module]s.Controllers
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Policy = "EditModule")]
|
||||
public [Module] Post([FromBody] [Module] [Module])
|
||||
public Models.[Module] Post([FromBody] Models.[Module] [Module])
|
||||
{
|
||||
if (ModelState.IsValid && [Module].ModuleId == _entityId)
|
||||
{
|
||||
[Module] = _[Module]s.Add[Module]([Module]);
|
||||
[Module] = _[Module]Repository.Add[Module]([Module]);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
|
||||
}
|
||||
return [Module];
|
||||
@ -65,11 +65,11 @@ namespace [Owner].[Module]s.Controllers
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = "EditModule")]
|
||||
public [Module] Put(int id, [FromBody] [Module] [Module])
|
||||
public Models.[Module] Put(int id, [FromBody] Models.[Module] [Module])
|
||||
{
|
||||
if (ModelState.IsValid && [Module].ModuleId == _entityId)
|
||||
{
|
||||
[Module] = _[Module]s.Update[Module]([Module]);
|
||||
[Module] = _[Module]Repository.Update[Module]([Module]);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
|
||||
}
|
||||
return [Module];
|
||||
@ -80,10 +80,10 @@ namespace [Owner].[Module]s.Controllers
|
||||
[Authorize(Policy = "EditModule")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
[Module] [Module] = _[Module]s.Get[Module](id);
|
||||
Models.[Module] [Module] = _[Module]Repository.Get[Module](id);
|
||||
if ([Module] != null && [Module].ModuleId == _entityId)
|
||||
{
|
||||
_[Module]s.Delete[Module](id);
|
||||
_[Module]Repository.Delete[Module](id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository;
|
||||
using [Owner].[Module].Models;
|
||||
using [Owner].[Module].Repository;
|
||||
|
||||
namespace [Owner].[Module].Manager
|
||||
{
|
||||
public class [Module]Manager : IInstallable, IPortable
|
||||
{
|
||||
private I[Module]Repository _[Module]Repository;
|
||||
private ISqlRepository _sql;
|
||||
|
||||
public [Module]Manager(I[Module]Repository [Module]Repository, ISqlRepository sql)
|
||||
{
|
||||
_[Module]Repository = [Module]Repository;
|
||||
_sql = sql;
|
||||
}
|
||||
|
||||
public bool Install(Tenant tenant, string version)
|
||||
{
|
||||
return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module]." + version + ".sql");
|
||||
}
|
||||
|
||||
public bool Uninstall(Tenant tenant)
|
||||
{
|
||||
return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module].Uninstall.sql");
|
||||
}
|
||||
|
||||
public string ExportModule(Module module)
|
||||
{
|
||||
string content = "";
|
||||
List<Models.[Module]> [Module]s = _[Module]Repository.Get[Module]s(module.ModuleId).ToList();
|
||||
if ([Module]s != null)
|
||||
{
|
||||
content = JsonSerializer.Serialize([Module]s);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
public void ImportModule(Module module, string content, string version)
|
||||
{
|
||||
List<Models.[Module]> [Module]s = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
[Module]s = JsonSerializer.Deserialize<List<Models.[Module]>>(content);
|
||||
}
|
||||
if ([Module]s != null)
|
||||
{
|
||||
foreach(var [Module] in [Module]s)
|
||||
{
|
||||
_[Module]Repository.Add[Module](new Models.[Module] { ModuleId = module.ModuleId, Name = [Module].Name });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using [Owner].[Module].Models;
|
||||
|
||||
namespace [Owner].[Module].Repository
|
||||
{
|
||||
public interface I[Module]Repository
|
||||
{
|
||||
IEnumerable<Models.[Module]> Get[Module]s(int ModuleId);
|
||||
Models.[Module] Get[Module](int [Module]Id);
|
||||
Models.[Module] Add[Module](Models.[Module] [Module]);
|
||||
Models.[Module] Update[Module](Models.[Module] [Module]);
|
||||
void Delete[Module](int [Module]Id);
|
||||
}
|
||||
}
|
@ -2,13 +2,13 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Repository;
|
||||
using [Owner].[Module]s.Models;
|
||||
using [Owner].[Module].Models;
|
||||
|
||||
namespace [Owner].[Module]s.Repository
|
||||
namespace [Owner].[Module].Repository
|
||||
{
|
||||
public class [Module]Context : DBContextBase, IService
|
||||
{
|
||||
public virtual DbSet<[Module]> [Module] { get; set; }
|
||||
public virtual DbSet<Models.[Module]> [Module] { get; set; }
|
||||
|
||||
public [Module]Context(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
|
||||
{
|
@ -2,9 +2,9 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Modules;
|
||||
using [Owner].[Module]s.Models;
|
||||
using [Owner].[Module].Models;
|
||||
|
||||
namespace [Owner].[Module]s.Repository
|
||||
namespace [Owner].[Module].Repository
|
||||
{
|
||||
public class [Module]Repository : I[Module]Repository, IService
|
||||
{
|
||||
@ -15,24 +15,24 @@ namespace [Owner].[Module]s.Repository
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<[Module]> Get[Module]s(int ModuleId)
|
||||
public IEnumerable<Models.[Module]> Get[Module]s(int ModuleId)
|
||||
{
|
||||
return _db.[Module].Where(item => item.ModuleId == ModuleId);
|
||||
}
|
||||
|
||||
public [Module] Get[Module](int [Module]Id)
|
||||
public Models.[Module] Get[Module](int [Module]Id)
|
||||
{
|
||||
return _db.[Module].Find([Module]Id);
|
||||
}
|
||||
|
||||
public [Module] Add[Module]([Module] [Module])
|
||||
public Models.[Module] Add[Module](Models.[Module] [Module])
|
||||
{
|
||||
_db.[Module].Add([Module]);
|
||||
_db.SaveChanges();
|
||||
return [Module];
|
||||
}
|
||||
|
||||
public [Module] Update[Module]([Module] [Module])
|
||||
public Models.[Module] Update[Module](Models.[Module] [Module])
|
||||
{
|
||||
_db.Entry([Module]).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
@ -41,7 +41,7 @@ namespace [Owner].[Module]s.Repository
|
||||
|
||||
public void Delete[Module](int [Module]Id)
|
||||
{
|
||||
[Module] [Module] = _db.[Module].Find([Module]Id);
|
||||
Models.[Module] [Module] = _db.[Module].Find([Module]Id);
|
||||
_db.[Module].Remove([Module]);
|
||||
_db.SaveChanges();
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository;
|
||||
using [Owner].[Module]s.Models;
|
||||
using [Owner].[Module]s.Repository;
|
||||
|
||||
namespace [Owner].[Module]s.Manager
|
||||
{
|
||||
public class [Module]Manager : IPortable
|
||||
{
|
||||
private I[Module]Repository _[Module]s;
|
||||
|
||||
public [Module]Manager(I[Module]Repository [Module]s)
|
||||
{
|
||||
_[Module]s = [Module]s;
|
||||
}
|
||||
|
||||
public string ExportModule(Module module)
|
||||
{
|
||||
string content = "";
|
||||
List<[Module]> [Module]s = _[Module]s.Get[Module]s(module.ModuleId).ToList();
|
||||
if ([Module]s != null)
|
||||
{
|
||||
content = JsonSerializer.Serialize([Module]s);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
public void ImportModule(Module module, string content, string version)
|
||||
{
|
||||
List<[Module]> [Module]s = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
[Module]s = JsonSerializer.Deserialize<List<[Module]>>(content);
|
||||
}
|
||||
if ([Module]s != null)
|
||||
{
|
||||
foreach([Module] [Module] in [Module]s)
|
||||
{
|
||||
[Module] _[Module] = new [Module]();
|
||||
_[Module].ModuleId = module.ModuleId;
|
||||
_[Module].Name = [Module].Name;
|
||||
_[Module]s.Add[Module](_[Module]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Repository
|
||||
{
|
||||
public interface I[Module]Repository
|
||||
{
|
||||
IEnumerable<[Module]> Get[Module]s(int ModuleId);
|
||||
[Module] Get[Module](int [Module]Id);
|
||||
[Module] Add[Module]([Module] [Module]);
|
||||
[Module] Update[Module]([Module] [Module]);
|
||||
void Delete[Module](int [Module]Id);
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Models
|
||||
namespace [Owner].[Module].Models
|
||||
{
|
||||
[Table("[Owner][Module]")]
|
||||
public class [Module] : IAuditable
|
Reference in New Issue
Block a user