SQL maanager, Module Creator, module settings enhancements
This commit is contained in:
58
Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor
Normal file
58
Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor
Normal file
@ -0,0 +1,58 @@
|
||||
@namespace Oqtane.Modules.Admin.ModuleCreator
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
@inject IModuleService ModuleService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label">Module Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label">Description: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@_description" rows="5"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<button type="button" class="btn btn-success" @onclick="CreateModule">Create Module</button>
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }
|
||||
|
||||
string _name = "";
|
||||
string _description = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AddModuleMessage("Please Note That Once You Select The Create Module Button The Application Must Restart In Order To Complete The Process.", MessageType.Info);
|
||||
}
|
||||
|
||||
private async Task CreateModule()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_name))
|
||||
{
|
||||
ModuleDefinition moduleDefinition = new ModuleDefinition { Name = _name, Description = _description };
|
||||
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage("You Must Provide A Name For The Module", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Creating Module");
|
||||
}
|
||||
}
|
||||
}
|
22
Oqtane.Client/Modules/Admin/ModuleCreator/Module.cs
Normal file
22
Oqtane.Client/Modules/Admin/ModuleCreator/Module.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Modules.Admin.ModuleCreator
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Name", "Module Creator" },
|
||||
{ "Description", "Enables software developers to quickly create modules by automating many of the initial module creation tasks" },
|
||||
{ "Version", "1.0.0" },
|
||||
{ "Categories", "Developer" }
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
@namespace Oqtane.Modules.[Module]s
|
||||
@using Oqtane.Services.[Module]s
|
||||
@using Oqtane.Models.[Module]s
|
||||
@using Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject I[Module]Service [Module]Service
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="_name" class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="Save">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
<br />
|
||||
@if (PageState.Action == "Edit")
|
||||
{
|
||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } }
|
||||
public override string Actions { get { return "Add,Edit"; } }
|
||||
|
||||
int _id;
|
||||
string _name;
|
||||
string _createdby;
|
||||
DateTime _createdon;
|
||||
string _modifiedby;
|
||||
DateTime _modifiedon;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (PageState.Action == "Edit")
|
||||
{
|
||||
try
|
||||
{
|
||||
_id = Int32.Parse(PageState.QueryString["id"]);
|
||||
[Module] [Module] = await [Module]Service.Get[Module]Async(_id);
|
||||
if ([Module] != null)
|
||||
{
|
||||
_name = [Module].Name;
|
||||
_createdby = [Module].CreatedBy;
|
||||
_createdon = [Module].CreatedOn;
|
||||
_modifiedby = [Module].ModifiedBy;
|
||||
_modifiedon = [Module].ModifiedOn;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading [Module] {[Module]Id} {Error}", _id, ex.Message);
|
||||
AddModuleMessage("Error Loading [Module]", MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (PageState.Action == "Add")
|
||||
{
|
||||
[Module] [Module] = new [Module]();
|
||||
[Module].ModuleId = ModuleState.ModuleId;
|
||||
[Module].Name = _name;
|
||||
[Module] = await [Module]Service.Add[Module]Async([Module]);
|
||||
await logger.LogInformation("[Module] Added {[Module]}", [Module]);
|
||||
}
|
||||
else
|
||||
{
|
||||
[Module] [Module] = await [Module]Service.Get[Module]Async(_id);
|
||||
[Module].Name = _name;
|
||||
await [Module]Service.Update[Module]Async([Module]);
|
||||
await logger.LogInformation("[Module] Updated {[Module]}", [Module]);
|
||||
}
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Saving [Module] {Error}", ex.Message);
|
||||
AddModuleMessage("Error Saving [Module]", MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
@namespace Oqtane.Modules.[Module]s
|
||||
@using Oqtane.Services.[Module]s
|
||||
@using Oqtane.Models.[Module]s
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject I[Module]Service [Module]Service
|
||||
|
||||
@if (_[Module]s == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Security="SecurityAccessLevel.Edit" Text="Add [Module]" />
|
||||
<br /><br />
|
||||
<Pager Items="@_[Module]s" Format="Grid">
|
||||
<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>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
|
||||
<hr />
|
||||
[Module] Module Created Successfully. You Can Access The Files At The Following Locations:<br /><br />
|
||||
C:\Users\Shaun.Walker\Source\Repos\sbwalker\oqtane.framework\Oqtane.Client\Modules\[Module]\<br />
|
||||
- Index.razor - main component for your module<br />
|
||||
- Edit.razor - component for adding or editing content<br />
|
||||
- Settings.razor - component for managing module settings<br />
|
||||
- Module.cs - implements IModule interface to provide configuration settings for your module<br />
|
||||
- Services\I[Module]Service.cs - interface for defining service API methods<br />
|
||||
- Services\[Module]Service.cs - implements service API interface methods<br /><br />
|
||||
C:\Users\Shaun.Walker\Source\Repos\sbwalker\oqtane.framework\Oqtane.Server\Modules\[Module]\<br />
|
||||
- Controllers\[Module]Controller.cs - API methods implemented using a REST pattern<br />
|
||||
- Manager\[Module]Manager.cs - implements optional module interfaces for features such as import/export of content<br />
|
||||
- Repository\I[Module]Repository.cs - interface for defining repository methods<br />
|
||||
- Repository\[Module]Respository.cs - implements repository interface methods for data access using EF Core<br />
|
||||
- Repository\[Module]Context.cs - provides a DB Context for data access<br />
|
||||
- Scripts\01.00.00.sql - database schema definition<br /><br />
|
||||
C:\Users\Shaun.Walker\Source\Repos\sbwalker\oqtane.framework\Oqtane.Shared\Modules\Models\[Module]\<br />
|
||||
- [Module].cs - model definition<br /><br />
|
||||
|
||||
@code {
|
||||
List<[Module]> _[Module]s;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading [Module] {Error}", ex.Message);
|
||||
AddModuleMessage("Error Loading [Module]", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Delete([Module] [Module])
|
||||
{
|
||||
try
|
||||
{
|
||||
await [Module]Service.Delete[Module]Async([Module].[Module]Id);
|
||||
await logger.LogInformation("[Module] Deleted {[Module]}", [Module]);
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Deleting [Module] {[Module]} {Error}", [Module], ex.Message);
|
||||
AddModuleMessage("Error Deleting [Module]", MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Oqtane.Models.[Module]s;
|
||||
|
||||
namespace Oqtane.Services.[Module]s
|
||||
{
|
||||
public interface I[Module]Service
|
||||
{
|
||||
Task<List<[Module]>> Get[Module]sAsync(int ModuleId);
|
||||
|
||||
Task<[Module]> Get[Module]Async(int [Module]Id);
|
||||
|
||||
Task<[Module]> Add[Module]Async([Module] [Module]);
|
||||
|
||||
Task<[Module]> Update[Module]Async([Module] [Module]);
|
||||
|
||||
Task Delete[Module]Async(int [Module]Id);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Services.[Module]s
|
||||
{
|
||||
public class [Module]Service : ServiceBase, I[Module]Service, IService
|
||||
{
|
||||
private readonly HttpClient _http;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
private readonly SiteState _siteState;
|
||||
|
||||
public [Module]Service(HttpClient http, SiteState siteState, NavigationManager navigationManager)
|
||||
{
|
||||
_http = http;
|
||||
_siteState = siteState;
|
||||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "[Module]"); }
|
||||
}
|
||||
|
||||
public async Task<List<[Module]>> Get[Module]sAsync(int ModuleId)
|
||||
{
|
||||
List<[Module]> [Module]s = await _http.GetJsonAsync<List<[Module]>>(Apiurl + "?moduleid=" + ModuleId.ToString());
|
||||
return [Module]s.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<[Module]> Get[Module]Async(int [Module]Id)
|
||||
{
|
||||
return await _http.GetJsonAsync<[Module]>(Apiurl + "/" + [Module]Id.ToString());
|
||||
}
|
||||
|
||||
public async Task<[Module]> Add[Module]Async([Module] [Module])
|
||||
{
|
||||
return await _http.PostJsonAsync<[Module]>(Apiurl + "?entityid=" + [Module].ModuleId, [Module]);
|
||||
}
|
||||
|
||||
public async Task<[Module]> Update[Module]Async([Module] [Module])
|
||||
{
|
||||
return await _http.PutJsonAsync<[Module]>(Apiurl + "/" + [Module].[Module]Id + "?entityid=" + [Module].ModuleId, [Module]);
|
||||
}
|
||||
|
||||
public async Task Delete[Module]Async(int [Module]Id)
|
||||
{
|
||||
await _http.DeleteAsync(Apiurl + "/" + [Module]Id.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
@namespace Oqtane.Modules.[Module]s
|
||||
@inherits ModuleBase
|
||||
@inject ISettingService SettingService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Setting" class="control-label">Setting: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" @bind="_value" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@code {
|
||||
public override string Title { get { return "[Module] Settings"; } }
|
||||
|
||||
string _value;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||
_value = SettingService.GetSetting(settings, "SettingName", "");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||
SettingService.SetSetting(settings, "SettingName", _value);
|
||||
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oqtane.Modules.[Module]s
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<string, string> properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Name", "[Module]" },
|
||||
{ "Description", "[Module]" },
|
||||
{ "Version", "1.0.0" },
|
||||
{ "ServerAssemblyName", "Oqtane.Server" }
|
||||
};
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Repository.[Module]s;
|
||||
using Oqtane.Shared;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
|
||||
namespace Oqtane.Controllers.[Module]s
|
||||
{
|
||||
[Route("{site}/api/[controller]")]
|
||||
public class [Module]Controller : Controller
|
||||
{
|
||||
private readonly I[Module]Repository _[Module]s;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public [Module]Controller(I[Module]Repository [Module]s, ILogManager logger)
|
||||
{
|
||||
_[Module]s = [Module]s;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?moduleid=x
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public IEnumerable<[Module]> Get(string moduleid)
|
||||
{
|
||||
return _[Module]s.Get[Module]s(int.Parse(moduleid));
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public [Module] Get(int id)
|
||||
{
|
||||
return _[Module]s.Get[Module](id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public [Module] Post([FromBody] [Module] [Module])
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
[Module] = _[Module]s.Add[Module]([Module]);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
|
||||
}
|
||||
return [Module];
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public [Module] Put(int id, [FromBody] [Module] [Module])
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
[Module] = _[Module]s.Update[Module]([Module]);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
|
||||
}
|
||||
return [Module];
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_[Module]s.Delete[Module](id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Repository.[Module]s;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Oqtane.Modules.[Module]s
|
||||
{
|
||||
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(Models.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(Models.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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models.[Module]s;
|
||||
|
||||
namespace Oqtane.Repository.[Module]s
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace Oqtane.Repository.[Module]s
|
||||
{
|
||||
public class [Module]Context : DBContextBase, IService
|
||||
{
|
||||
public virtual DbSet<[Module]> [Module] { get; set; }
|
||||
|
||||
public [Module]Context(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
|
||||
{
|
||||
// ContextBase handles multi-tenant database connections
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace Oqtane.Repository.[Module]s
|
||||
{
|
||||
public class [Module]Repository : I[Module]Repository, IService
|
||||
{
|
||||
private readonly [Module]Context _db;
|
||||
|
||||
public [Module]Repository([Module]Context context)
|
||||
{
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<[Module]> Get[Module]s(int ModuleId)
|
||||
{
|
||||
return _db.[Module].Where(item => item.ModuleId == ModuleId);
|
||||
}
|
||||
|
||||
public [Module] Get[Module](int [Module]Id)
|
||||
{
|
||||
return _db.[Module].Find([Module]Id);
|
||||
}
|
||||
|
||||
public [Module] Add[Module]([Module] [Module])
|
||||
{
|
||||
_db.[Module].Add([Module]);
|
||||
_db.SaveChanges();
|
||||
return [Module];
|
||||
}
|
||||
|
||||
public [Module] Update[Module]([Module] [Module])
|
||||
{
|
||||
_db.Entry([Module]).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return [Module];
|
||||
}
|
||||
|
||||
public void Delete[Module](int [Module]Id)
|
||||
{
|
||||
[Module] [Module] = _db.[Module].Find([Module]Id);
|
||||
_db.[Module].Remove([Module]);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Create [Module] table
|
||||
*/
|
||||
|
||||
CREATE TABLE [dbo].[[Module]](
|
||||
[[Module]Id] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ModuleId] [int] NOT NULL,
|
||||
[Name] [nvarchar](256) NOT NULL,
|
||||
[CreatedBy] [nvarchar](256) NOT NULL,
|
||||
[CreatedOn] [datetime] NOT NULL,
|
||||
[ModifiedBy] [nvarchar](256) NOT NULL,
|
||||
[ModifiedOn] [datetime] NOT NULL,
|
||||
CONSTRAINT [PK_[Module]] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[[Module]Id] ASC
|
||||
)
|
||||
)
|
||||
GO
|
||||
|
||||
/*
|
||||
Create foreign key relationships
|
||||
*/
|
||||
ALTER TABLE [dbo].[[Module]] WITH CHECK ADD CONSTRAINT [FK_[Module]_Module] FOREIGN KEY([ModuleId])
|
||||
REFERENCES [dbo].Module ([ModuleId])
|
||||
ON DELETE CASCADE
|
||||
GO
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Oqtane.Models.[Module]s
|
||||
{
|
||||
public class [Module] : IAuditable
|
||||
{
|
||||
[Key]
|
||||
public int [Module]Id { get; set; }
|
||||
public int ModuleId { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public string CreatedBy { get; set; }
|
||||
public DateTime CreatedOn { get; set; }
|
||||
public string ModifiedBy { get; set; }
|
||||
public DateTime ModifiedOn { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user