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.
This commit is contained in:
22
DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml.cs
Normal file
22
DXApp.TemplateKitProject/Pages/Invoices/Details.cshtml.cs
Normal file
@@ -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<IActionResult> OnGetAsync(int id)
|
||||
{
|
||||
Invoice = await db.ZugferdInvoices.FirstOrDefaultAsync(i => i.Id == id);
|
||||
|
||||
if (Invoice is null)
|
||||
return NotFound();
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user