Fix and harden prospect creation against Blazor runtime crashes
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 3m3s

- Handle empty numeric input safely with nullable integer binding.

- Add semaphore locks to prevent double-click invocation errors on mobile.

- Implement global exception handling and user notifications for prospect operations.
This commit is contained in:
troogs
2026-05-10 19:47:39 +02:00
parent e1c57967e4
commit 935f026c75
2 changed files with 35 additions and 10 deletions

View File

@@ -96,16 +96,34 @@ namespace FoodsharingSiegen.Server.Dialogs
if (IsUpdateMode) if (IsUpdateMode)
{ {
var updateR = await ProspectService.UpdateAsync(Prospect); var updateR = await ProspectService.UpdateAsync(Prospect);
if (updateR.Success && OnSuccess != null) await OnSuccess.Invoke(); if (updateR.Success)
{
if (OnSuccess != null) await OnSuccess.Invoke();
await ModalService.Hide();
}
else
{
await Notification.Error(updateR.Exception?.Message ?? "Unbekannter Fehler beim Speichern.", "Fehler");
}
} }
else else
{ {
var addR = await ProspectService.AddProspectAsync(Prospect); var addR = await ProspectService.AddProspectAsync(Prospect);
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke(); if (addR.Success)
} {
if (OnSuccess != null) await OnSuccess.Invoke();
await ModalService.Hide(); await ModalService.Hide();
} }
else
{
await Notification.Error(addR.Exception?.Message ?? "Unbekannter Fehler beim Hinzufügen.", "Fehler");
}
}
}
catch (Exception ex)
{
await Notification.Error(ex.Message, "Systemfehler");
}
finally finally
{ {
_isSaving = false; _isSaving = false;

View File

@@ -99,6 +99,8 @@ namespace FoodsharingSiegen.Server.Pages
/// Loads the prospects (a. beging, 11.04.2022) /// Loads the prospects (a. beging, 11.04.2022)
/// </summary> /// </summary>
private async Task LoadProspects() private async Task LoadProspects()
{
try
{ {
var parameter = new GetProspectsParameter var parameter = new GetProspectsParameter
{ {
@@ -110,6 +112,11 @@ namespace FoodsharingSiegen.Server.Pages
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
} }
catch (Exception ex)
{
await Notification.Error(ex.Message, "Fehler beim Laden");
}
}
#endregion #endregion
} }