AddressSelector & Blazorise

This commit is contained in:
Andre Beging
2024-11-07 13:16:00 +01:00
parent 07bd63c450
commit 6091b54b2a
8 changed files with 181 additions and 8 deletions

View File

@@ -1,7 +1,9 @@
using Microsoft.AspNetCore.Components;
using Blazorise;
using Microsoft.AspNetCore.Components;
using QuestPDF;
using QuestPDF.Fluent;
using QuestPDF.Infrastructure;
using Server.Components.Dialogs;
using Server.Data;
using Server.Model;
@@ -11,6 +13,9 @@ namespace Server.Components.Pages
{
#region Dependencies
[Inject]
private IModalService ModalService { get; set; } = null!;
[Inject]
private NavigationManager NavigationManager { get; set; } = null!;
@@ -18,6 +23,13 @@ namespace Server.Components.Pages
#region Parameters
/// <summary>
/// Gets or sets the identifier for the invoice.
/// </summary>
/// <remarks>
/// This property is used to uniquely identify an invoice.
/// It is a nullable string which allows handling cases where no invoice ID is provided.
/// </remarks>
[Parameter]
public string? InvoiceId { get; set; }
@@ -25,10 +37,10 @@ namespace Server.Components.Pages
#region Private Properties
private InvoiceModel Invoice { get; set; } = new();
private string? AlertMessage { get; set; }
private InvoiceModel Invoice { get; set; } = new();
#endregion
#region Override SetParametersAsync
@@ -44,7 +56,7 @@ namespace Server.Components.Pages
NavigationManager.NavigateTo("/");
return;
}
// Existing
var invoice = await InvoiceData.LoadAsync(InvoiceId);
if (invoice == null)
@@ -143,11 +155,24 @@ namespace Server.Components.Pages
private async Task SaveInvoiceAsync()
{
AlertMessage = null;
await InvoiceData.SaveAsync(Invoice);
NavigationManager.NavigateTo("/invoices");
}
#endregion
#region Private Method SelectCustomerAsync
private async Task SelectCustomerAsync()
{
await AddressSelector.ShowAsync(ModalService, async address =>
{
Invoice.Customer = address;
await InvokeAsync(StateHasChanged);
});
}
#endregion
}
}