Store Filter between pages

This commit is contained in:
Andre Beging
2025-04-02 07:47:33 +02:00
parent 6d6d79f55a
commit b7ba95b716
10 changed files with 103 additions and 11 deletions

View File

@@ -1,8 +1,10 @@
using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs;
using FoodsharingSiegen.Server.Service;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages
@@ -14,17 +16,14 @@ namespace FoodsharingSiegen.Server.Pages
{
#region Dependencies
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject]
public ProspectService ProspectService { get; set; } = null!;
private ProspectService ProspectService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the user service (ab)
/// </summary>
[Inject]
public UserService UserService { get; set; } = null!;
private UserService UserService { get; set; } = null!;
#endregion
@@ -44,6 +43,9 @@ namespace FoodsharingSiegen.Server.Pages
/// <inheritdoc />
protected override async Task InitializeDataAsync()
{
var filter = await LocalStorageService.GetItem<ProspectFilter>(StorageKeys.ProspectFilter);
if (filter != null) Filter = filter;
// Load prospects
await LoadProspects();
}
@@ -63,6 +65,21 @@ namespace FoodsharingSiegen.Server.Pages
#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>