Compare commits
3 Commits
78135a9f6d
...
935f026c75
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
935f026c75 | ||
|
|
e1c57967e4 | ||
|
|
c702e8dbd5 |
@@ -11,7 +11,7 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<Field>
|
<Field>
|
||||||
<FieldLabel>Foodsharing-ID</FieldLabel>
|
<FieldLabel>Foodsharing-ID</FieldLabel>
|
||||||
<NumericEdit TValue="int" @bind-Value="Prospect.FsId"></NumericEdit>
|
<NumericEdit TValue="int?" Value="Prospect.FsId" ValueChanged="@((int? v) => Prospect.FsId = v ?? 0)"></NumericEdit>
|
||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -82,23 +82,52 @@ namespace FoodsharingSiegen.Server.Dialogs
|
|||||||
|
|
||||||
#region Private Method SaveClick
|
#region Private Method SaveClick
|
||||||
|
|
||||||
|
private bool _isSaving;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the click (a. beging, 31.05.2022)
|
/// Saves the click (a. beging, 31.05.2022)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task SaveClick()
|
private async Task SaveClick()
|
||||||
{
|
{
|
||||||
if (IsUpdateMode)
|
if (_isSaving) return;
|
||||||
|
_isSaving = true;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var updateR = await ProspectService.UpdateAsync(Prospect);
|
if (IsUpdateMode)
|
||||||
if (updateR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
{
|
||||||
|
var updateR = await ProspectService.UpdateAsync(Prospect);
|
||||||
|
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
|
||||||
|
{
|
||||||
|
var addR = await ProspectService.AddProspectAsync(Prospect);
|
||||||
|
if (addR.Success)
|
||||||
|
{
|
||||||
|
if (OnSuccess != null) await OnSuccess.Invoke();
|
||||||
|
await ModalService.Hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Notification.Error(addR.Exception?.Message ?? "Unbekannter Fehler beim Hinzufügen.", "Fehler");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var addR = await ProspectService.AddProspectAsync(Prospect);
|
await Notification.Error(ex.Message, "Systemfehler");
|
||||||
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isSaving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ModalService.Hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -56,13 +56,24 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
#region Private Method CreateProspectAsync
|
#region Private Method CreateProspectAsync
|
||||||
|
|
||||||
|
private bool _isOpeningModal;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously creates a new prospect by displaying the AddProspectModal dialog and refreshing the prospect list.
|
/// Asynchronously creates a new prospect by displaying the AddProspectModal dialog and refreshing the prospect list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||||
private async Task CreateProspectAsync()
|
private async Task CreateProspectAsync()
|
||||||
{
|
{
|
||||||
await EditProspectDialog.ShowAsync(ModalService, LoadProspects);
|
if (_isOpeningModal) return;
|
||||||
|
_isOpeningModal = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await EditProspectDialog.ShowAsync(ModalService, LoadProspects);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isOpeningModal = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -89,15 +100,22 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task LoadProspects()
|
private async Task LoadProspects()
|
||||||
{
|
{
|
||||||
var parameter = new GetProspectsParameter
|
try
|
||||||
{
|
{
|
||||||
CannotHaveInteractions = [InteractionType.Complete, InteractionType.Verify, InteractionType.ReleasedForVerification]
|
var parameter = new GetProspectsParameter
|
||||||
};
|
{
|
||||||
|
CannotHaveInteractions = [InteractionType.Complete, InteractionType.Verify, InteractionType.ReleasedForVerification]
|
||||||
|
};
|
||||||
|
|
||||||
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
|
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
|
||||||
if (prospectsR.Success) ProspectList = prospectsR.Data;
|
if (prospectsR.Success) ProspectList = prospectsR.Data;
|
||||||
|
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await Notification.Error(ex.Message, "Fehler beim Laden");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user