@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.Shared; @inherits ModuleBase @inject IUriHelper UriHelper @inject HttpClient http @inject SiteState sitestate
@code { public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } } public override string Title { get { return "Edit Html/Text"; } } string content; protected override async Task OnInitializedAsync() { HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper); HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); if (htmltext != null) { content = htmltext.Content; } } private async Task SaveContent() { HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper); 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); } PageState.Reload = Constants.ReloadPage; UriHelper.NavigateTo(NavigateUrl()); } }