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