Added indexes for `ImportedAt` and a composite key on `InvoiceNumber` and `SellerTaxId` to improve query performance. Updated `AppDbContext` and EF Core migrations to reflect these changes. Introduced `ZugferdInvoiceListDto` to optimize memory usage by excluding large fields like `RawXml`. Updated the frontend (`Index.cshtml`) and backend (`Index.cshtml.cs`) to use the new DTO for better performance.
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
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<ZugferdInvoiceListDto> Invoices { get; private set; } = [];
|
|
|
|
public async Task OnGetAsync()
|
|
{
|
|
Invoices = await db.ZugferdInvoices
|
|
.OrderByDescending(i => i.ImportedAt)
|
|
.Select(i => new ZugferdInvoiceListDto
|
|
{
|
|
Id = i.Id,
|
|
InvoiceNumber = i.InvoiceNumber,
|
|
InvoiceDate = i.InvoiceDate,
|
|
SellerName = i.SellerName,
|
|
SellerTaxId = i.SellerTaxId,
|
|
BuyerName = i.BuyerName,
|
|
TotalAmount = i.TotalAmount,
|
|
TaxAmount = i.TaxAmount,
|
|
CurrencyCode = i.CurrencyCode,
|
|
Iban = i.Iban,
|
|
ImportedAt = i.ImportedAt,
|
|
SourceType = i.SourceType,
|
|
ResultFilePath = i.ResultFilePath,
|
|
GuidelineId = i.GuidelineId
|
|
// RawXml wird NICHT geladen ? Performance-Optimierung!
|
|
})
|
|
.ToListAsync();
|
|
}
|
|
}
|