76 lines
2.4 KiB
C#
76 lines
2.4 KiB
C#
using Blazorise;
|
|
using FoodsharingSiegen.Contracts.Entity;
|
|
using FoodsharingSiegen.Server.Data.Service;
|
|
using FoodsharingSiegen.Server.Dialogs;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace FoodsharingSiegen.Server.Pages
|
|
{
|
|
public partial class Prospects
|
|
{
|
|
[Inject] IMessageService MessageService { get; set; }
|
|
[Inject] public ProspectService ProspectService { get; set; } = null!;
|
|
[Inject] public UserService UserService { get; set; } = null!;
|
|
|
|
public List<Prospect>? ProspectList { get; set; }
|
|
|
|
public AddProspectModal ProspectModal { get; set; } = null!;
|
|
public AddInteractionModal InteractionModal { get; set; }
|
|
public List<User>? Users { get; set; }
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
await LoadProspects();
|
|
}
|
|
|
|
await base.OnAfterRenderAsync(firstRender);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var getUsersR = await UserService.GetUsersAsync();
|
|
if (getUsersR.Success)
|
|
Users = getUsersR.Data;
|
|
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private async Task LoadProspects()
|
|
{
|
|
var prospectsR = await ProspectService.GetProspectsAsync();
|
|
if (prospectsR.Success) ProspectList = prospectsR.Data;
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private async Task OnAddProspect(Prospect arg)
|
|
{
|
|
var addProspectR = await ProspectService.AddProspectAsync(arg);
|
|
if (addProspectR.Success) await LoadProspects();
|
|
}
|
|
|
|
private async Task OnAddInteraction(Interaction arg)
|
|
{
|
|
await ProspectService.AddInteraction(arg);
|
|
await LoadProspects();
|
|
}
|
|
|
|
private async Task RemoveInteraction(Guid arg)
|
|
{
|
|
var confirm = await MessageService.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();
|
|
}
|
|
|
|
}
|
|
}
|
|
} |