Files
FoodsharingOnboarding/FoodsharingSiegen.Server/Pages/ProspectsDone.razor.cs
2025-03-27 16:16:48 +01:00

102 lines
2.9 KiB
C#

using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Pages
{
/// <summary>
/// The prospects done class (a. beging, 07.02.2023)
/// </summary>
public partial class ProspectsDone
{
#region Dependencies
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject]
public ProspectService ProspectService { get; set; } = null!;
#endregion
#region Private Properties
/// <summary>
/// Gets or sets the value of the filter text (ab)
/// </summary>
private string? FilterText { get; set; }
/// <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()
{
await LoadProspects();
}
#endregion
#region Private Method FilterText_Changed
/// <summary>
/// Filters the text changed using the specified filter text (a. beging, 08.02.2023)
/// </summary>
/// <param name="filterText">The filter text</param>
private void FilterText_Changed(string filterText)
{
FilterText = filterText;
}
#endregion
#region Private Method LoadProspects
/// <summary>
/// Loads the prospects (a. beging, 11.04.2022)
/// </summary>
private async Task LoadProspects()
{
var parameter = new GetProspectsParameter { MustHaveInteractions = new() { InteractionType.Complete } };
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
if (prospectsR.Success) ProspectList = prospectsR.Data;
await InvokeAsync(StateHasChanged);
}
#endregion
#region Private Method RemoveInteraction
/// <summary>
/// Removes the interaction using the specified arg (a. beging, 11.04.2022)
/// </summary>
/// <param name="arg">The arg</param>
private async Task RemoveInteraction(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
}
}