Add project files.

This commit is contained in:
OlgunR
2026-05-21 14:35:02 +02:00
parent b315aead20
commit dc551c2313
106 changed files with 303666 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using DXApp.TemplateKitProject.Models;
using DXApp.TemplateKitProject.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace DXApp.TemplateKitProject.Pages.Invoices;
public class UploadModel(
PdfAttachmentExtractorService extractor,
ILogger<UploadModel> logger) : PageModel
{
[BindProperty]
public IFormFile? PdfFile { get; set; }
public PdfExtractionResult? Result { get; private set; }
public bool ExtractionDone { get; private set; }
public string? ErrorMessage { get; private set; }
public void OnGet()
{ }
public async Task<IActionResult> OnPostAsync()
{
if (PdfFile is null || PdfFile.Length == 0)
{
ModelState.AddModelError(nameof(PdfFile), "Bitte eine PDF-Datei auswählen.");
return Page();
}
if (!PdfFile.FileName.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase))
{
ModelState.AddModelError(nameof(PdfFile), "Nur PDF-Dateien sind erlaubt.");
return Page();
}
ExtractionDone = true;
try
{
await using var stream = PdfFile.OpenReadStream();
Result = extractor.ExtractAttachments(stream, PdfFile.FileName);
}
catch (Exception ex)
{
logger.LogError(ex, "Fehler beim Verarbeiten der Datei '{FileName}'.", PdfFile.FileName);
ErrorMessage = $"Fehler beim Verarbeiten der Datei: {ex.Message}";
}
return Page();
}
}