protected override async Task OnInitializedAsync() { try { var htmltext = await HtmlTextService.GetHtmlTextAsync(ModuleState.ModuleId); if (htmltext != null) { _content = htmltext.Content; _content = _content.Replace(Constants.ContentUrl, "/" + PageState.Alias.AliasId.ToString() + Constants.ContentUrl); _createdby = htmltext.CreatedBy; _createdon = htmltext.CreatedOn; _modifiedby = htmltext.ModifiedBy; _modifiedon = htmltext.ModifiedOn; } else { _content = string.Empty; } } catch (Exception ex) { await logger.LogError(ex, "An Error Occurred Loading Html/Text Content. " + ex.Message); AddModuleMessage(ex.Message, MessageType.Error); } }
private async Task SaveContent() { string content = await RichTextEditorHtml.GetHtml(); content = content.Replace("/" + PageState.Alias.AliasId.ToString() + Constants.ContentUrl, Constants.ContentUrl); try { var 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); } await logger.LogInformation("Html/Text Content Saved {HtmlText}", htmltext); NavigationManager.NavigateTo(NavigateUrl()); } catch (Exception ex) { await logger.LogError(ex, "Error Saving Content {Error}", ex.Message); AddModuleMessage("Error Saving Content", MessageType.Error); } }
protected override async Task OnParametersSetAsync() { try { var htmltext = await HtmlTextService.GetHtmlTextAsync(ModuleState.ModuleId); if (htmltext != null) { content = htmltext.Content; content = content.Replace(Constants.ContentUrl, "/" + PageState.Alias.AliasId.ToString() + Constants.ContentUrl); } } catch (Exception ex) { await logger.LogError(ex, "An Error Occurred Loading Html/Text Content. " + ex.Message); AddModuleMessage(ex.Message, MessageType.Error); } }