@using SZUAbsolventenverein.Module.PremiumArea.Services @using SZUAbsolventenverein.Module.PremiumArea.Models @namespace SZUAbsolventenverein.Module.PremiumArea @inherits ModuleBase @inject IEngineerApplicationService ApplicationService @inject NavigationManager NavManager @inject IStringLocalizer Localizer

@Localizer["Ingenieur Antrag"]

@if (!string.IsNullOrEmpty(_message)) {
@_message
}
@if (_showForm) {

Bitte laden Sie Ihren Ingenieur-Antrag als PDF-Datei hoch.

@*
Max Größe: 20MB. Format: Nur PDF.
*@
} else { @if (_existingApp.FileId > 0) {
Ihr Antrag

Status: Veröffentlicht

@if (!string.IsNullOrEmpty(_existingApp.Title)) {

Titel: @_existingApp.Title

} @if (!string.IsNullOrEmpty(_existingApp.ShortDescription)) {

Kurzbeschreibung: @_existingApp.ShortDescription

}

Datum: @_existingApp.CreatedOn.ToShortDateString()

} } @code { public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; private EngineerApplication _existingApp = new EngineerApplication(); private bool _showForm = true; private string _message = ""; protected override async Task OnInitializedAsync() { try { var apps = await ApplicationService.GetApplicationsAsync(ModuleState.ModuleId); var userId = PageState.User?.UserId ?? -1; _existingApp.Status = "New"; _existingApp = apps.FirstOrDefault(a => a.UserId == userId, _existingApp); if (_existingApp.FileId > 0) { _showForm = false; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } private void EditApp() { _showForm = true; } private async Task SubmitApplication() { if (_existingApp == null || _existingApp.FileId == 0) { _message = "Bitte wählen Sie eine Datei aus."; return; } try { var app = new EngineerApplication { ApplicationId = _existingApp?.ApplicationId ?? 0, ModuleId = ModuleState.ModuleId, UserId = PageState.User.UserId, FileId = _existingApp.FileId, Title = _existingApp.Title, ShortDescription = _existingApp.ShortDescription, Status = "Published", // Auto-publish SubmittedOn = DateTime.UtcNow, ApprovedOn = DateTime.UtcNow, // Auto-approved }; if (app.ApplicationId == 0) { var result = await ApplicationService.AddApplicationAsync(app); _existingApp = result; } else { await ApplicationService.UpdateApplicationAsync(app); _existingApp = await ApplicationService.GetApplicationAsync(app.ApplicationId, ModuleState.ModuleId); } _showForm = false; _message = "Antrag erfolgreich veröffentlicht."; } catch (Exception ex) { _message = "Fehler: " + ex.Message; } } private void Cancel() { NavManager.NavigateTo(NavigateUrl()); } private Task OnSelectFile(int fileId) { _existingApp.FileId = fileId; return Task.CompletedTask; } }