@using Interfaces @using Oqtane.Modules.Controls @using SZUAbsolventenverein.Module.BlackBoard.Services @using SZUAbsolventenverein.Module.BlackBoard.Models @namespace SZUAbsolventenverein.Module.BlackBoard @inherits ModuleBase @inject IBlackBoardService BlackBoardService @inject NavigationManager NavigationManager @inject IStringLocalizer Localizer @inject IReportUI ReportingComponent
@Localizer["Cancel"] @if (ReportingComponent != null) { }

@if (PageState.Action == "Edit") { } @code { public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; public override string RenderMode => RenderModes.Interactive; public override string Actions => "Add,Edit"; public override string Title => "Manage BlackBoard"; public override List Resources => [new Stylesheet("_content/SZUAbsolventenverein.Module.BlackBoard/Module.css")]; private RichTextEditor RichTextEditorHtml; private ElementReference form; private bool validated; private int _id; // TODO private BlackBoard _blackBoard = new BlackBoard(); private Dictionary _parameters = new Dictionary(); protected override async Task OnInitializedAsync() { try { if (PageState.Action == "Edit") { _id = Int32.Parse(PageState.QueryString["id"]); _blackBoard = await BlackBoardService.GetBlackBoardAsync(_id, ModuleState.ModuleId); if (_blackBoard != null) { _parameters = ReportingComponent.ConstructParameterList(_blackBoard, RenderModeBoundary); } } } catch (Exception ex) { await logger.LogError(ex, "Error Loading BlackBoard {BlackBoardId} {Error}", _id, ex.Message); AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error); } } private Task OnFileSelected(int fileId) { Console.WriteLine("File Selected: " + fileId); _blackBoard.ImageID = fileId; return Task.CompletedTask; } private async Task Save() { try { validated = true; var interop = new Oqtane.UI.Interop(JSRuntime); if (await interop.FormValid(form)) { _blackBoard.Description = await RichTextEditorHtml.GetHtml(); if (PageState.Action == "Add") { _blackBoard.ModuleId = ModuleState.ModuleId; _blackBoard = await BlackBoardService.AddBlackBoardAsync(_blackBoard); await logger.LogInformation("BlackBoard Added {BlackBoard}", _blackBoard); } else { await BlackBoardService.UpdateBlackBoardAsync(_blackBoard); await logger.LogInformation("BlackBoard Updated {BlackBoard}", _blackBoard); } NavigationManager.NavigateTo(NavigateUrl()); } else { AddModuleMessage(Localizer["Message.SaveValidation"], MessageType.Warning); } } catch (Exception ex) { await logger.LogError(ex, "Error Saving BlackBoard {Error}", ex.Message); AddModuleMessage(Localizer["Message.SaveError"], MessageType.Error); } } }