Fix EditProspectDialog and Prospects: prevent multiple modal openings during save and create operations
This commit is contained in:
@@ -82,23 +82,34 @@ namespace FoodsharingSiegen.Server.Dialogs
|
||||
|
||||
#region Private Method SaveClick
|
||||
|
||||
private bool _isSaving;
|
||||
|
||||
/// <summary>
|
||||
/// Saves the click (a. beging, 31.05.2022)
|
||||
/// </summary>
|
||||
private async Task SaveClick()
|
||||
{
|
||||
if (IsUpdateMode)
|
||||
if (_isSaving) return;
|
||||
_isSaving = true;
|
||||
try
|
||||
{
|
||||
var updateR = await ProspectService.UpdateAsync(Prospect);
|
||||
if (updateR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
var addR = await ProspectService.AddProspectAsync(Prospect);
|
||||
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
||||
}
|
||||
if (IsUpdateMode)
|
||||
{
|
||||
var updateR = await ProspectService.UpdateAsync(Prospect);
|
||||
if (updateR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
var addR = await ProspectService.AddProspectAsync(Prospect);
|
||||
if (addR.Success && OnSuccess != null) await OnSuccess.Invoke();
|
||||
}
|
||||
|
||||
await ModalService.Hide();
|
||||
await ModalService.Hide();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user