@using Microsoft.EntityFrameworkCore
@using StandManager.Components.Layout
@using System.Threading.Tasks
@using StandManager.Model
@page "/RegistrazioneInFiera"
@layout PublicLayout
@rendermode InteractiveServer
Iscrizione Evento
@if (showCodiceCliente)
{
}
@if (showForm)
{
}
@code {
private bool showCodiceCliente { get; set; } = false;
private bool showForm { get; set; } = false;
private InvitoEventoViewModel invito { get; set; } = new InvitoEventoViewModel();
private Component_Registrazione registrazione { get; set; } = new();
private string codiceFornito { get; set; }
private void onClienteToggleChanged(bool value)
{
if (!value)
registrazione.NoCliente();
else
registrazione.HasCliente();
showCodiceCliente = value;
showForm = true;
}
private async Task onCodiceFornitoChanged(string text)
{
codiceFornito = text;
invito.CodiceFornito = codiceFornito;
var destinazione = (await _managerService.DestinazioneService.RicercaPer(
x => x.PartitaIva == codiceFornito || x.CodiceFiscale == codiceFornito || x.Rid == codiceFornito || x.Cliente.Rid == codiceFornito,
includi: x => x.Include(y => y.Cliente)));
if (destinazione != null)
{
invito.ClienteId = destinazione.ClienteId;
invito.DestinazioneId = destinazione.Id;
invito.CodiceFornito = codiceFornito;
invito.RagioneSociale = destinazione.Cliente?.RagioneSociale ?? string.Empty;
await registrazione.SetDatiCliente();
}
showForm = true;
}
}