Files
Andre Beging 6389da4bc1 Rename 'Deleted' state to 'Archived' and update related logic
Replaced 'Deleted' with 'Archived' across the codebase to better reflect the intent of the state. Adjusted related features, including filters, UI labels, navigation, and permissions. Introduced a 'Recent Activity' filter for improved activity tracking.
2025-04-02 08:40:38 +02:00

96 lines
2.9 KiB
C#

using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Helper;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages
{
/// <summary>
/// The prospects done class (a. beging, 07.02.2023)
/// </summary>
public partial class ProspectsAll
{
#region Dependencies
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject]
public ProspectService ProspectService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the user service (ab)
/// </summary>
[Inject]
public UserService UserService { get; set; } = null!;
#endregion
#region Private Properties
private ProspectFilter Filter { get; set; } = new();
/// <summary>
/// Gets or sets the value of the prospect list (ab)
/// </summary>
private List<Prospect>? ProspectList { get; set; }
#endregion
#region Override InitializeDataAsync
/// <inheritdoc />
protected override async Task InitializeDataAsync()
{
if(!CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador)) NavigationManager.NavigateTo("/");
// Load Filter
var filter = await LocalStorageService.GetItem<ProspectFilter>(StorageKeys.ProspectFilter);
if (filter != null) Filter = filter;
// Load prospects
await LoadProspects();
}
#endregion
#region Private Method FilterChangedAsync
/// <summary>
/// Updates the current filter with the specified ProspectFilter object.
/// </summary>
/// <param name="arg">The ProspectFilter object containing the updated filter criteria.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
private async Task FilterChangedAsync(ProspectFilter arg)
{
Filter = arg;
await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
}
#endregion
#region Private Method LoadProspects
/// <summary>
/// Loads the prospects (a. beging, 11.04.2022)
/// </summary>
private async Task LoadProspects()
{
var parameter = new GetProspectsParameter
{
IncludeDeleted = true
};
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;
await InvokeAsync(StateHasChanged);
}
#endregion
}
}