82 lines
2.6 KiB
Plaintext
82 lines
2.6 KiB
Plaintext
@using Oqtane.Modules.HtmlText.Services
|
|
@using Oqtane.Modules.HtmlText.Models
|
|
@namespace Oqtane.Modules.HtmlText
|
|
@inherits ModuleBase
|
|
@inject NavigationManager NavigationManager
|
|
@inject HttpClient http
|
|
@inject SiteState sitestate
|
|
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td>
|
|
<label for="Name" class="control-label">Content: </label>
|
|
</td>
|
|
<td>
|
|
<textarea class="form-control" @bind="@content" rows="5" />
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<button type="button" class="btn btn-success" @onclick="SaveContent">Save</button>
|
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
|
<br />
|
|
<br />
|
|
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
|
|
|
|
@code {
|
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } }
|
|
public override string Title { get { return "Edit Html/Text"; } }
|
|
|
|
string content;
|
|
string createdby;
|
|
DateTime createdon;
|
|
string modifiedby;
|
|
DateTime modifiedon;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
|
|
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
|
if (htmltext != null)
|
|
{
|
|
content = htmltext.Content;
|
|
createdby = htmltext.CreatedBy;
|
|
createdon = htmltext.CreatedOn;
|
|
modifiedby = htmltext.ModifiedBy;
|
|
modifiedon = htmltext.ModifiedOn;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
AddModuleMessage(ex.Message, MessageType.Error);
|
|
}
|
|
}
|
|
|
|
private async Task SaveContent()
|
|
{
|
|
try
|
|
{
|
|
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, NavigationManager);
|
|
HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
|
if (htmltext != null)
|
|
{
|
|
htmltext.Content = content;
|
|
await htmltextservice.UpdateHtmlTextAsync(htmltext);
|
|
}
|
|
else
|
|
{
|
|
htmltext = new HtmlTextInfo();
|
|
htmltext.ModuleId = ModuleState.ModuleId;
|
|
htmltext.Content = content;
|
|
await htmltextservice.AddHtmlTextAsync(htmltext);
|
|
}
|
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Page));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
AddModuleMessage(ex.Message, MessageType.Error);
|
|
}
|
|
}
|
|
}
|