From 5221ee35941d6a7c9bc36e1d3ddda87151e59e59 Mon Sep 17 00:00:00 2001 From: OlgunR Date: Fri, 22 May 2026 14:30:11 +0200 Subject: [PATCH] Add invoices page and navigation menu items Added new navigation menu items in `_Layout.cshtml` for "Rechnungen" (Invoices) and "PDF hochladen" (Upload PDF) with icons, paths, and selection logic. Created a new Razor Page `Index.cshtml` to display imported invoices using a `DataGrid` with features like filtering, paging, and column formatting. Added a conditional message for when no invoices are available. Implemented the `IndexModel` class in `Index.cshtml.cs` to handle backend logic, including fetching and sorting invoices from the database using `AppDbContext`. --- .../Pages/Invoices/Index.cshtml | 55 +++++++++++++++++++ .../Pages/Invoices/Index.cshtml.cs | 18 ++++++ .../Pages/Shared/_Layout.cshtml | 12 ++++ 3 files changed, 85 insertions(+) create mode 100644 DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml create mode 100644 DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml.cs diff --git a/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml b/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml new file mode 100644 index 0000000..9ad1c6c --- /dev/null +++ b/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml @@ -0,0 +1,55 @@ +@page +@model DXApp.TemplateKitProject.Pages.Invoices.IndexModel +@{ + ViewData["Title"] = "Rechnungen"; +} + +

Importierte Rechnungen

+ +@if (!Model.Invoices.Any()) +{ +
Noch keine Rechnungen importiert.
+} +else +{ + @(Html.DevExtreme().DataGrid() + .DataSource(Model.Invoices) + .KeyExpr("Id") + .ShowBorders(true) + .RowAlternationEnabled(true) + .FilterRow(f => f.Visible(true)) + .HeaderFilter(h => h.Visible(true)) + .Paging(p => p.PageSize(20)) + .Pager(p => p + .ShowPageSizeSelector(true) + .AllowedPageSizes(new[] { 10, 20, 50 }) + .ShowInfo(true) + ) + .Columns(cols => + { + cols.Add().DataField("Id").Caption("ID").Width(60).AllowEditing(false); + cols.Add().DataField("InvoiceNumber").Caption("Rechnungsnr."); + cols.Add().DataField("InvoiceDate").Caption("Datum") + .DataType(GridColumnDataType.Date) + .Format("dd.MM.yyyy") + .Width(110); + cols.Add().DataField("SellerName").Caption("Verkäufer"); + cols.Add().DataField("BuyerName").Caption("Käufer"); + cols.Add().DataField("TotalAmount").Caption("Gesamt") + .DataType(GridColumnDataType.Number) + .Format("#,##0.00") + .Width(110); + cols.Add().DataField("TaxAmount").Caption("MwSt.") + .DataType(GridColumnDataType.Number) + .Format("#,##0.00") + .Width(100); + cols.Add().DataField("CurrencyCode").Caption("Währung").Width(80); + cols.Add().DataField("Iban").Caption("IBAN"); + cols.Add().DataField("SourceType").Caption("Quelle").Width(90); + cols.Add().DataField("ImportedAt").Caption("Importiert am") + .DataType(GridColumnDataType.DateTime) + .Format("dd.MM.yyyy HH:mm") + .Width(150); + }) + ) +} diff --git a/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml.cs b/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml.cs new file mode 100644 index 0000000..c49647a --- /dev/null +++ b/DXApp.TemplateKitProject/Pages/Invoices/Index.cshtml.cs @@ -0,0 +1,18 @@ +using DXApp.TemplateKitProject.Data; +using DXApp.TemplateKitProject.Models; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.EntityFrameworkCore; + +namespace DXApp.TemplateKitProject.Pages.Invoices; + +public class IndexModel(AppDbContext db) : PageModel +{ + public List Invoices { get; private set; } = []; + + public async Task OnGetAsync() + { + Invoices = await db.ZugferdInvoices + .OrderByDescending(i => i.ImportedAt) + .ToListAsync(); + } +} diff --git a/DXApp.TemplateKitProject/Pages/Shared/_Layout.cshtml b/DXApp.TemplateKitProject/Pages/Shared/_Layout.cshtml index 70ff7e9..e52490f 100644 --- a/DXApp.TemplateKitProject/Pages/Shared/_Layout.cshtml +++ b/DXApp.TemplateKitProject/Pages/Shared/_Layout.cshtml @@ -84,6 +84,18 @@ .Icon("info") .Option("path", GetUrl("/About")) .Selected(IsCurrentUrl("/About")); + + items.Add() + .Text("Rechnungen") + .Icon("doc") + .Option("path", GetUrl("/Invoices/Index")) + .Selected(IsCurrentUrl("/Invoices/Index")); + + items.Add() + .Text("PDF hochladen") + .Icon("upload") + .Option("path", GetUrl("/Invoices/Upload")) + .Selected(IsCurrentUrl("/Invoices/Upload")); }) .ExpandEvent(TreeViewExpandEvent.Click) .SelectionMode(NavSelectionMode.Single)