diff --git a/StandManager/Components/Pages/Component_Conferma_Iscrizione.razor b/StandManager/Components/Pages/Component_Conferma_Iscrizione.razor new file mode 100644 index 0000000..afd2e58 --- /dev/null +++ b/StandManager/Components/Pages/Component_Conferma_Iscrizione.razor @@ -0,0 +1,31 @@ +@inject Radzen.DialogService DialogService + +
+
+

Benvenuto @RagioneSociale.

+

Confermare la presenza?

+ +
+ + +
+ +
+
+ +
+
+ +
+
+
+
+ +@code { + [Parameter] public string RagioneSociale { get; set; } + [Parameter] public int Partecipanti { get; set; } +} \ No newline at end of file diff --git a/StandManager/Components/Pages/ScanNew.razor b/StandManager/Components/Pages/ScanNew.razor index 782a883..8f7a4e0 100644 --- a/StandManager/Components/Pages/ScanNew.razor +++ b/StandManager/Components/Pages/ScanNew.razor @@ -1,21 +1,28 @@ @page "/activate-qr-scan" @using StandManager.Components.Layout +@using Microsoft.JSInterop +@implements IAsyncDisposable @inject NavigationManager Nav @layout PublicLayout @inject IJSRuntime JS @inject BodyClassService BodyClass +@inject Radzen.DialogService _dialogService +@inject IManagerService _managerService + @rendermode InteractiveServer Scan Code + + +
-
} - + @if (openScan) + { +
+
+
+ + +
+
+ +

Inquadra il QR Code

+
+ + @if (!string.IsNullOrWhiteSpace(invalidCode)) + { +
+
+
+ Errore: @invalidCode +
+
+
+ +
+
+ } + +
+ +
+
+ } + @if (!openManual && !openScan) { -
- @@ -108,16 +156,25 @@ @code { [Parameter] public EventCallback Close { get; set; } [Parameter] public EventCallback Help { get; set; } - [Parameter] public EventCallback Scan { get; set; } - [Parameter] public EventCallback Manual { get; set; } private bool openManual { get; set; } = false; private bool openScan { get; set; } = false; - private string registrationCode { get; set; } - private string invalidCode = string.Empty; + private string registrationCode { get; set; } = string.Empty; + private string invalidCode { get; set; } = string.Empty; + + // Scanner + private ElementReference videoRef; + private DotNetObjectReference? objRef; + private bool isScanning; + + protected override void OnInitialized() + { + objRef = DotNetObjectReference.Create(this); + } private async Task OnClose() { + if (isScanning) await StopScan(); Nav.NavigateTo("/"); } @@ -125,32 +182,142 @@ { } - private async Task OnScan() - { - - } - - private async Task OnManual() + private void OnManual() { openManual = true; + invalidCode = string.Empty; } private async Task GoTo() { - var code = Guid.Empty; - - if (Guid.TryParse(registrationCode, out code)) + if (Guid.TryParse(registrationCode, out var code)) { - var iscrizione = await _managerService.IscrizioneEventoService.RicercaPer(filtro: x => x.Id == code); + var iscrizione = await _managerService.IscrizioneEventoService.RicercaPer(filtro: x => x.Id == code, solaLettura: false); - var ok = await _dialogService.Confirm($"Il numero di persone indicate per questo evento è {iscrizione.Partecipanti}", $"Benvenuto {iscrizione.RagioneSociale}", new ConfirmOptions { OkButtonText = "Sì", CancelButtonText = "No", Width = "400px" }); + if (iscrizione != null) + { + invalidCode = string.Empty; + + var result = await _dialogService.OpenAsync("Conferma Numero Partecipanti", + new Dictionary() { + { "RagioneSociale", iscrizione.RagioneSociale }, + { "Partecipanti", iscrizione.Partecipanti } + }, + new DialogOptions() { Width = "400px", CloseDialogOnOverlayClick = false } + ); + + if (result == null) await Reset(); + + var numPartecipanti = (int)result; + + iscrizione.ScanCompleto = true; + iscrizione.DataScan = DateTime.Now; + iscrizione.Partecipanti = numPartecipanti; + await _managerService.IscrizioneEventoService.Salva(iscrizione); + + await Reset(); + } + else + { + invalidCode = "Codice non trovato."; + } + } + else + { + invalidCode = "Il codice inserito non risulta corretto!"; } - else invalidCode = "Il codice inserito non risulta corretto!"; } private async Task UndoChoice() { openManual = false; + registrationCode = string.Empty; + await StopScan(); openScan = false; } -} + + private async Task OnScan() + { + openScan = true; + // Delay per crazione tag