Darstellung der Prospects fragmentiert

This commit is contained in:
Andre Beging
2023-02-07 23:13:09 +01:00
parent 1b59a9461b
commit df40e2b769
12 changed files with 317 additions and 39 deletions

View File

@@ -0,0 +1,93 @@
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 ProspectsTodo
{
#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 prospect list (ab)
/// </summary>
private List<Prospect>? ProspectList { get; set; }
#endregion
#region Override OnAfterRenderAsync
/// <summary>
/// Ons the after render using the specified first render (a. beging, 11.04.2022)
/// </summary>
/// <param name="firstRender">The first render</param>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await LoadProspects();
await base.OnAfterRenderAsync(firstRender);
}
#endregion
#region Private Method LoadProspects
/// <summary>
/// Loads the prospects (a. beging, 11.04.2022)
/// </summary>
private async Task LoadProspects()
{
var parameter = new GetProspectsParameter
{
CannotHaveInteractions = new List<InteractionType> { InteractionType.Complete },
MustHaveInteractions = new List<InteractionType> { InteractionType.Verify }
};
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
}
}