Introduced a new "All" prospects page for admins to view and manage all prospects. Removed unused "Users" list and related logic from code. Updated filters to support the new "All" state and adjusted navigation to include the new page.
111 lines
3.2 KiB
C#
111 lines
3.2 KiB
C#
using FoodsharingSiegen.Contracts.Entity;
|
|
using FoodsharingSiegen.Contracts.Model;
|
|
using FoodsharingSiegen.Server.Data.Service;
|
|
using FoodsharingSiegen.Server.Dialogs;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace FoodsharingSiegen.Server.Pages
|
|
{
|
|
/// <summary>
|
|
/// The prospects class (a. beging, 11.04.2022)
|
|
/// </summary>
|
|
public partial class Prospects
|
|
{
|
|
#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()
|
|
{
|
|
// Load prospects
|
|
await LoadProspects();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Method CreateProspectAsync
|
|
|
|
/// <summary>
|
|
/// Asynchronously creates a new prospect by displaying the AddProspectModal dialog and refreshing the prospect list.
|
|
/// </summary>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
private async Task CreateProspectAsync()
|
|
{
|
|
await EditProspectDialog.ShowAsync(ModalService, LoadProspects);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Method LoadProspects
|
|
|
|
/// <summary>
|
|
/// Loads the prospects (a. beging, 11.04.2022)
|
|
/// </summary>
|
|
private async Task LoadProspects()
|
|
{
|
|
var parameter = new GetProspectsParameter
|
|
{
|
|
CannotHaveInteractions = [InteractionType.Complete, InteractionType.Verify, InteractionType.ReleasedForVerification]
|
|
};
|
|
|
|
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
|
|
if (prospectsR.Success) ProspectList = prospectsR.Data;
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Method RemoveInteractionAsync
|
|
|
|
/// <summary>
|
|
/// Removes the interaction using the specified arg (a. beging, 11.04.2022)
|
|
/// </summary>
|
|
/// <param name="arg">The arg</param>
|
|
private async Task RemoveInteractionAsync(Guid arg)
|
|
{
|
|
var confirm = await Message.Confirm("Interaktion wirklich löschen?", "Bestätigen", o =>
|
|
{
|
|
o.ConfirmButtonText = "Ja, wirklich!";
|
|
o.CancelButtonText = "Abbrechen";
|
|
o.ShowMessageIcon = false;
|
|
});
|
|
|
|
if (confirm)
|
|
{
|
|
await ProspectService.RemoveInteraction(arg);
|
|
await LoadProspects();
|
|
}
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |