Edit prospect
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Blazorise;
|
||||
using Blazorise;
|
||||
using FoodsharingSiegen.Contracts.Entity;
|
||||
using FoodsharingSiegen.Server.Data.Service;
|
||||
using FoodsharingSiegen.Server.Dialogs;
|
||||
@@ -6,18 +6,60 @@ using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace FoodsharingSiegen.Server.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// The prospects class (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
public partial class Prospects
|
||||
{
|
||||
#region Dependencies (Injected)
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the message service (ab)
|
||||
/// </summary>
|
||||
[Inject] IMessageService MessageService { get; set; }
|
||||
|
||||
/// <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!;
|
||||
|
||||
public List<Prospect>? ProspectList { get; set; }
|
||||
|
||||
public AddProspectModal ProspectModal { get; set; } = null!;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the interaction modal (ab)
|
||||
/// </summary>
|
||||
public AddInteractionModal InteractionModal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the prospect list (ab)
|
||||
/// </summary>
|
||||
public List<Prospect>? ProspectList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the prospect modal (ab)
|
||||
/// </summary>
|
||||
public AddProspectModal ProspectModal { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the users (ab)
|
||||
/// </summary>
|
||||
public List<User>? Users { 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)
|
||||
@@ -28,6 +70,13 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override OnInitializedAsync
|
||||
|
||||
/// <summary>
|
||||
/// Ons the initialized (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var getUsersR = await UserService.GetUsersAsync();
|
||||
@@ -37,6 +86,13 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method LoadProspects
|
||||
|
||||
/// <summary>
|
||||
/// Loads the prospects (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
private async Task LoadProspects()
|
||||
{
|
||||
var prospectsR = await ProspectService.GetProspectsAsync();
|
||||
@@ -45,18 +101,56 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task OnAddProspect(Prospect arg)
|
||||
{
|
||||
var addProspectR = await ProspectService.AddProspectAsync(arg);
|
||||
if (addProspectR.Success) await LoadProspects();
|
||||
}
|
||||
#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)
|
||||
{
|
||||
await ProspectService.AddInteraction(arg);
|
||||
await LoadProspects();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method OnAddProspect
|
||||
|
||||
/// <summary>
|
||||
/// Ons the add prospect using the specified arg (a. beging, 11.04.2022)
|
||||
/// </summary>
|
||||
/// <param name="arg">The arg</param>
|
||||
private async Task OnAddProspect(Prospect arg)
|
||||
{
|
||||
var addProspectR = await ProspectService.AddProspectAsync(arg);
|
||||
if (addProspectR.Success) 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 MessageService.Confirm("Interaktion wirklich löschen?", "Bestätigen", o => {
|
||||
@@ -70,7 +164,8 @@ namespace FoodsharingSiegen.Server.Pages
|
||||
await ProspectService.RemoveInteraction(arg);
|
||||
await LoadProspects();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user