AddressSelector & Blazorise
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
@page "/edit/{InvoiceId}"
|
||||
@using Server.Data
|
||||
@using Server.Model
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@@ -33,6 +34,27 @@
|
||||
<InputDate class="form-control" @bind-Value="@Invoice.IssueDate"></InputDate>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
@if (Invoice.Customer != null)
|
||||
{
|
||||
<div class="card mb-2" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">@Invoice.Customer.Name</h5>
|
||||
<p class="card-text">
|
||||
@Invoice.Customer.Name2<br>
|
||||
@Invoice.Customer.Street<br>
|
||||
@Invoice.Customer.Zip - @Invoice.Customer.City<br>
|
||||
@Invoice.Customer.Phone
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<button class="btn btn-secondary" @onclick="SelectCustomerAsync">@(Invoice.Customer != null ? "Kunden ändern" : "Kunden auswählen")</button>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label" >Rechnungsnummer</label>
|
||||
<InputText class="form-control" @bind-Value="@Invoice.InvoiceId" disabled></InputText>
|
||||
@@ -83,4 +105,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<ModalProvider />
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user