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 OnAdd { get; set; } [Parameter] public List? Users { get; set; } public Guid SelectedUser { get; set; } private string _header; private string _infoName; private bool _showInfo; private bool _showAlert; 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; _showNotNeeded = false; _showAlert = false; _infoName = "Kommentar"; switch (type) { case InteractionType.EinAb: _header = "Einführung eintragen"; _showInfo = true; _showAlert = true; _infoName = "Welcher Betrieb?"; break; case InteractionType.Welcome: _header = "Begrüßung eintragen"; break; case InteractionType.IdCheck: _header = "Ausweisprüfung eintragen"; _showAlert = true; _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(); } } }