65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using QuestPDF.Fluent;
|
|
using QuestPDF.Infrastructure;
|
|
using Server.Data;
|
|
using Server.Model;
|
|
|
|
namespace Server.Components.Pages
|
|
{
|
|
public partial class InvoiceListPage : ComponentBase
|
|
{
|
|
#region Private Properties
|
|
|
|
private List<InvoiceModel>? Invoices { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Override SetParametersAsync
|
|
|
|
//// <inheritdoc />
|
|
public override async Task SetParametersAsync(ParameterView parameters)
|
|
{
|
|
parameters.SetParameterProperties(this);
|
|
|
|
await SettingsData.LoadAsync();
|
|
Invoices = await InvoiceData.LoadAllAsync();
|
|
|
|
await base.SetParametersAsync(ParameterView.Empty);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Method DeleteInvoiceAsync
|
|
|
|
/// <summary>
|
|
/// Deletes an invoice asynchronously by its ID.
|
|
/// </summary>
|
|
/// <param name="invoiceInvoiceId">The ID of the invoice to be deleted.</param>
|
|
/// <returns>A task representing the asynchronous delete operation.</returns>
|
|
private async Task DeleteInvoiceAsync(string? invoiceInvoiceId)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(invoiceInvoiceId)) return;
|
|
await InvoiceData.DeleteAsync(invoiceInvoiceId);
|
|
Invoices = await InvoiceData.LoadAllAsync();
|
|
}
|
|
|
|
#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
|
|
}
|
|
} |