Add RecordState handling for prospects and support soft deletion

Introduced the RecordState property to manage the state of prospects, enabling soft deletion and restoration. Updated related database migrations, UI interactions, and filtering logic to accommodate this addition. Also included automatic database migration at runtime to ensure schema compatibility.
This commit is contained in:
Andre Beging
2025-03-29 13:49:47 +01:00
parent 16023a89e9
commit c2de397a0f
15 changed files with 404 additions and 33 deletions

View File

@@ -48,6 +48,26 @@ namespace FoodsharingSiegen.Server.Controls
#endregion
#region Private Method DeleteProspectAsync
/// <summary>
/// Deletes the currently selected prospect after user confirmation. This action is irreversible and will update the record state to "Deleted".
/// </summary>
/// <returns>A task that represents the asynchronous delete operation.</returns>
private async Task DeleteProspectAsync()
{
if (Prospect == null) return;
await ConfirmDialog.ShowAsync(ModalService, $"⚠️ {Prospect.Name} löschen", $"Soll {Prospect.Name} mit der FS-ID {Prospect.FsId} wirklich gelöscht werden? Das kann nicht rückgängig gemacht werden!!", async () =>
{
Prospect.RecordState = RecordState.Deleted;
var updateR = await ProspectService.UpdateAsync(Prospect);
if (updateR.Success && OnDataChanged != null) await OnDataChanged();
});
}
#endregion
#region Private Method EditProspectAsync
private async Task EditProspectAsync()
@@ -86,5 +106,25 @@ namespace FoodsharingSiegen.Server.Controls
}
#endregion
#region Private Method RestoreProspectAsync
/// <summary>
/// Restores the currently selected prospect after user confirmation. This action will update the record state to "Default".
/// </summary>
/// <returns>A task that represents the asynchronous restore operation.</returns>
private async Task RestoreProspectAsync()
{
if (Prospect == null) return;
await ConfirmDialog.ShowAsync(ModalService, $"{Prospect.Name} wiederherstellen", $"Soll {Prospect.Name} mit der FS-ID {Prospect.FsId} wiederhergestellt werden?", async () =>
{
Prospect.RecordState = RecordState.Default;
var updateR = await ProspectService.UpdateAsync(Prospect);
if (updateR.Success && OnDataChanged != null) await OnDataChanged();
});
}
#endregion
}
}