From 9adc9ac4ed22b6d1448cfd37d81d59cc83a47000 Mon Sep 17 00:00:00 2001 From: OlgunR Date: Thu, 28 May 2026 16:53:50 +0200 Subject: [PATCH] Add invoice details page and grid column link Added a "Details" column to the grid in `Index.cshtml` with a button linking to the new invoice details page. The button dynamically generates the URL using the invoice ID. Created `Details.cshtml` to display detailed invoice information, including metadata such as seller, buyer, amounts, and dates. Added a back button and error handling for missing invoices. Introduced `DetailsModel` in `Details.cshtml.cs` to fetch invoice data using `AppDbContext`. Implemented the `OnGetAsync` method to retrieve data asynchronously and handle cases where the invoice is not found. --- .../Pages/Invoices/Details.cshtml | 44 +++++++++++++++++++ .../Pages/Invoices/Details.cshtml.cs | 22 ++++++++++ .../Pages/Invoices/Index.cshtml | 10 +++++ 3 files changed, 76 insertions(+) create mode 100644 DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml create mode 100644 DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml.cs diff --git a/DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml b/DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml new file mode 100644 index 0000000..ddd7437 --- /dev/null +++ b/DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml @@ -0,0 +1,44 @@ +@page +@model DXApp.TemplateKitProject.Pages.Invoices.DetailsModel +@{ + ViewData["Title"] = "Rechnungsdetails"; +} + +

📄 Rechnungsdetails

+← Zurück zur Liste + +@if (Model.Invoice is null) +{ +
Rechnung nicht gefunden.
+} +else +{ + + + + + + + + + + + + + + + + + + +
ID@Model.Invoice.Id
Rechnungsnummer@Model.Invoice.InvoiceNumber
Rechnungsdatum@Model.Invoice.InvoiceDate.ToString("dd.MM.yyyy")
Verkäufer@Model.Invoice.SellerName
USt-ID Verkäufer@Model.Invoice.SellerTaxId
Käufer@Model.Invoice.BuyerName
Währung@Model.Invoice.CurrencyCode
Steuerbetrag@Model.Invoice.TaxAmount.ToString("N2")
Gesamtbetrag@Model.Invoice.TotalAmount.ToString("N2")
IBAN@Model.Invoice.Iban
Quelle@Model.Invoice.SourceType
Guideline-ID@Model.Invoice.GuidelineId
Importiert am@Model.Invoice.ImportedAt.ToString("dd.MM.yyyy HH:mm")
Result-PDF + @if (!string.IsNullOrEmpty(Model.Invoice.ResultFilePath)) + { + @Model.Invoice.ResultFilePath + } + else + { + – nicht vorhanden – + } +
+} \ No newline at end of file diff --git a/DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml.cs b/DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml.cs new file mode 100644 index 0000000..8a79c8f --- /dev/null +++ b/DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml.cs @@ -0,0 +1,22 @@ +using DXApp.TemplateKitProject.Data; +using DXApp.TemplateKitProject.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.EntityFrameworkCore; + +namespace DXApp.TemplateKitProject.Pages.Invoices; + +public class DetailsModel(AppDbContext db) : PageModel +{ + public ZugferdInvoice? Invoice { get; private set; } + + public async Task OnGetAsync(int id) + { + Invoice = await db.ZugferdInvoices.FirstOrDefaultAsync(i => i.Id == id); + + if (Invoice is null) + return NotFound(); + + return Page(); + } +} \ No newline at end of file diff --git a/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml b/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml index 9ad1c6c..aad760a 100644 --- a/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml +++ b/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml @@ -27,6 +27,16 @@ else ) .Columns(cols => { + cols.Add() + .Caption("Details") + .Width(80) + .CellTemplate(new JS(@"function(container, options) { + $('') + .attr('href', '/Invoices/Details?id=' + options.data.Id) + .attr('class', 'btn btn-sm btn-outline-primary') + .text('Details') + .appendTo(container); + }")); cols.Add().DataField("Id").Caption("ID").Width(60).AllowEditing(false); cols.Add().DataField("InvoiceNumber").Caption("Rechnungsnr."); cols.Add().DataField("InvoiceDate").Caption("Datum")