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
            .Include(i => i.Attachments)
            .FirstOrDefaultAsync(i => i.Id == id);

        if (Invoice is null)
            return NotFound();

        return Page();
    }
}