Files
FoodsharingOnboarding/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor.cs
2022-04-04 16:31:18 +02:00

89 lines
3.1 KiB
C#

using Blazorise;
using FoodsharingSiegen.Contracts.Entity;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Dialogs
{
public partial class AddInteractionModal
{
private Modal ModalReference { get; set; } = null!;
private Interaction Interaction { get; set; } = new();
[Parameter]
public EventCallback<Interaction> OnAdd { get; set; }
[Parameter]
public List<User>? Users { get; set; }
public Guid SelectedUser { get; set; }
private string _header;
private string _infoName;
private bool _showInfo;
private bool _showNotNeeded;
protected override async Task OnParametersSetAsync()
{
if (Users?.Any() == true)SelectedUser = Users.First().Id;
await base.OnParametersSetAsync();
}
public async Task Show(InteractionType type, Guid? prospectId)
{
if (prospectId == null) return;
_showInfo = false;
_infoName = "Kommentar";
switch (type)
{
case InteractionType.EinAb:
_header = "Einführung eintragen";
_showInfo = true;
_infoName = "Welcher Betrieb?";
break;
case InteractionType.Welcome:
_header = "Begrüßung eintragen";
break;
case InteractionType.IdCheck:
_header = "Ausweisprüfung eintragen";
_showInfo = true;
break;
case InteractionType.PrintPass:
_header = "FS-Ausweis (Print)";
_showNotNeeded = true;
_showInfo = true;
break;
case InteractionType.PdfPass:
_header = "FS-Ausweis (PDF)";
_showNotNeeded = true;
_showInfo = true;
break;
case InteractionType.Verify:
_header = "Verifizierung eintragen";
break;
case InteractionType.Complete:
_header = "Als fertig markieren";
_showInfo = true;
break;
}
Interaction = new Interaction
{
Type = type,
Date = DateTime.UtcNow,
ProspectId = prospectId.Value
};
await ModalReference.Show();
}
private async Task AddInteraction()
{
Interaction.UserId = SelectedUser;
await OnAdd.InvokeAsync(Interaction);
await ModalReference.Hide();
}
}
}