Initial commit
This commit is contained in:
61
Oqtane.Client/Modules/HtmlText/Edit.razor
Normal file
61
Oqtane.Client/Modules/HtmlText/Edit.razor
Normal file
@ -0,0 +1,61 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.HtmlText.Services
|
||||
@using Oqtane.Shared.Modules.HtmlText.Models
|
||||
@using System.Net.Http;
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject HttpClient http
|
||||
|
||||
<form>
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Content: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" bind="@content" rows="5" style="width:400px;" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn btn-success" onclick="@SaveContent">Save</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
</form>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Edit; } }
|
||||
public override string Title { get { return "Edit Html/Text"; } }
|
||||
|
||||
HtmlTextInfo htmltext;
|
||||
string content;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
|
||||
List<HtmlTextInfo> htmltextlist = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||
if (htmltextlist != null)
|
||||
{
|
||||
htmltext = htmltextlist.FirstOrDefault();
|
||||
content = htmltext.Content;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveContent()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
|
||||
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);
|
||||
}
|
||||
UriHelper.NavigateTo(NavigateUrl(), true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user