Layout Updates

This commit is contained in:
Andre Beging
2024-11-14 20:34:16 +01:00
parent b76dcdb746
commit 7dc50d51f9
7 changed files with 207 additions and 96 deletions

View File

@@ -21,9 +21,10 @@
@($"{invoice.TotalNetto:N2} €") Netto<br />
</p>
<a href="@($"edit/{invoice.InvoiceId}")" class="btn btn-sm btn-primary">Bearbeiten</a>
<button class="btn btn-sm btn-info" @onclick="() => GenerateDocumentAsync(invoice)"><i class="fas fa-file-pdf"></i></button>
@if (invoice.DeletionAllowed)
{
<button class="btn btn-sm btn-danger" style="margin-left: .5rem;" @onclick="() => DeleteInvoiceAsync(invoice.InvoiceId)">Löschen</button>
<button class="btn btn-sm btn-danger" style="margin-left: .5rem;" @onclick="() => DeleteInvoiceAsync(invoice.InvoiceId)"><i class="fas fa-trash"></i></button>
}
</div>
</div>

View File

@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Components;
using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
using Server.Data;
using Server.Model;
@@ -19,6 +21,7 @@ namespace Server.Components.Pages
{
parameters.SetParameterProperties(this);
await SettingsData.LoadAsync();
Invoices = await InvoiceData.LoadAllAsync();
await base.SetParametersAsync(ParameterView.Empty);
@@ -41,5 +44,22 @@ namespace Server.Components.Pages
}
#endregion
#region Private Method GenerateDocumentAsync
/// <summary>
/// Generates a PDF document asynchronously for the given invoice.
/// </summary>
/// <param name="invoice">The invoice model for which to generate the document.</param>
/// <returns>A task representing the asynchronous document generation operation.</returns>
private Task GenerateDocumentAsync(InvoiceModel invoice)
{
QuestPDF.Settings.License = LicenseType.Community;
var doc = new InvoiceDocument(invoice);
doc.GeneratePdfAndShow();
return Task.CompletedTask;
}
#endregion
}
}