Buildversion and FilterHelper
This commit is contained in:
144
FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs
Normal file
144
FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
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 done class (a. beging, 07.02.2023)
|
||||
/// </summary>
|
||||
public partial class ProspectsVerify
|
||||
{
|
||||
#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 interaction modal (ab)
|
||||
/// </summary>
|
||||
private AddInteractionModal? InteractionModal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the prospect list (ab)
|
||||
/// </summary>
|
||||
private List<Prospect>? ProspectList { get; set; }
|
||||
|
||||
private AddProspectModal? ProspectModal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the users (ab)
|
||||
/// </summary>
|
||||
private List<User>? Users { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override InitializeDataAsync
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task InitializeDataAsync()
|
||||
{
|
||||
// Load prospects
|
||||
await LoadProspects();
|
||||
|
||||
// Load users
|
||||
var getUsersR = await UserService.GetUsersAsync();
|
||||
if (getUsersR.Success)
|
||||
Users = getUsersR.Data;
|
||||
}
|
||||
|
||||
#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],
|
||||
MustHaveInteractions = [InteractionType.ReleasedForVerification]
|
||||
};
|
||||
var prospectsR = await ProspectService.GetProspectsAsync(parameter);
|
||||
if (prospectsR.Success) ProspectList = prospectsR.Data;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method OnAddInteraction
|
||||
|
||||
/// <summary>
|
||||
/// Ons the add interaction using the specified arg (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
/// <param name="arg">The arg</param>
|
||||
private async Task OnAddInteraction(Interaction arg)
|
||||
{
|
||||
arg.UserID = CurrentUser.Id;
|
||||
await ProspectService.AddInteraction(arg);
|
||||
await LoadProspects();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method OnUpdateProspect
|
||||
|
||||
/// <summary>
|
||||
/// Ons the update prospect using the specified prospect (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
/// <param name="prospect">The prospect</param>
|
||||
private async Task OnUpdateProspect(Prospect prospect)
|
||||
{
|
||||
var updateProspectR = await ProspectService.UpdateAsync(prospect);
|
||||
if (updateProspectR.Success) await LoadProspects();
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user