From 64a626628ca4abf3face421fea4db9dabc909362 Mon Sep 17 00:00:00 2001 From: Davide Sandrelli Date: Mon, 22 Dec 2025 17:47:23 +0100 Subject: [PATCH] - Comune/Provincia dropdown in Registrazione --- .../Pages/Component_Registrazione.razor | 18 ++++++----- StandManager/Model/ComuneIstatViewModel.cs | 31 +++++++++++++++++++ .../Model/IscrizioneEventoViewModel.cs | 6 ++-- 3 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 StandManager/Model/ComuneIstatViewModel.cs diff --git a/StandManager/Components/Pages/Component_Registrazione.razor b/StandManager/Components/Pages/Component_Registrazione.razor index 568a6f0..4177955 100644 --- a/StandManager/Components/Pages/Component_Registrazione.razor +++ b/StandManager/Components/Pages/Component_Registrazione.razor @@ -38,7 +38,7 @@
- @@ -51,7 +51,7 @@
- @@ -158,9 +158,9 @@ private IEnumerable> tipologiaList { get; set; } private IEnumerable esperienzaList { get; set; } private IEnumerable> ruoloList { get; set; } - + private List provList { get; set; } - private List comuniList { get; set; } + private List comuniList { get; set; } private bool presaVisionePrivacy { get; set; } private bool presaVisioneDatiPersonali { get; set; } @@ -192,6 +192,7 @@ DestinazioneId = iscrizione.DestinazioneId, TipologiaClienteId = iscrizione.TipologiaClienteId }; + if (invito.EventoId != Guid.Empty && iscrizione.DestinazioneId == Guid.Empty) { _dialogService.Alert("Selezionare una destinazione valida.", "Attenzione"); @@ -223,10 +224,10 @@ destinazioniList = new List() { new DestinazioneViewModel() { RagioneSociale = "--Nessuna" } }; } - private async Task onProvinciaChanged(ChangeEventArgs args) + private async Task onProvinciaChanged(object args) { Guid parsed; - var guidId = Guid.TryParse(args.Value?.ToString(), out parsed); + var guidId = Guid.TryParse(args.ToString(), out parsed); var prov = await _managerService.ProvinciaIstatService.RicercaPer(x => x.Id == parsed); if (prov == null) @@ -234,10 +235,11 @@ await _dialogService.Alert("La provincia indicata non è presente", "Errore", new ConfirmOptions() { OkButtonText = "Ok" }); return; } - + iscrizione.Provincia = prov.Id; + iscrizione.Comune = null; comuniList = (await _managerService.ComuneIstatService.RicercaQueryable(x => x.Provincia == prov.Sigla)) - .Select(x => (ComuneIstatExcelViewModel)x).ToList(); + .Select(x => (ComuneIstatViewModel)x).ToList(); } } \ No newline at end of file diff --git a/StandManager/Model/ComuneIstatViewModel.cs b/StandManager/Model/ComuneIstatViewModel.cs new file mode 100644 index 0000000..c10950e --- /dev/null +++ b/StandManager/Model/ComuneIstatViewModel.cs @@ -0,0 +1,31 @@ +using StandManager.Domain.Entita; + +namespace StandManager.Model; + +public class ComuneIstatViewModel +{ + public Guid Id { get; set; } + public string Istat { get; set; } + public string Comune { get; set; } + public string Regione { get; set; } + public string Provincia { get; set; } + public string Prefisso { get; set; } + public string CodFisco { get; set; } + public string Info => $"{Comune}"; + + public static implicit operator ComuneIstatViewModel(ComuneIstat model) + { + return model == null + ? null + : new ComuneIstatViewModel() + { + Id = model.Id, + Comune = model.Comune, + Istat = model.Istat, + Regione = model.Regione, + Provincia = model.Provincia, + Prefisso = model.Prefisso, + CodFisco = model.CodFisco + }; + } +} \ No newline at end of file diff --git a/StandManager/Model/IscrizioneEventoViewModel.cs b/StandManager/Model/IscrizioneEventoViewModel.cs index ae7f7e0..9dfe04e 100644 --- a/StandManager/Model/IscrizioneEventoViewModel.cs +++ b/StandManager/Model/IscrizioneEventoViewModel.cs @@ -28,7 +28,7 @@ public class IscrizioneEventoViewModel [Required(ErrorMessage = "La provincia è obbigatoria")] public Guid Provincia { get; set; } [Required(ErrorMessage = "Il comune è obbigatorio")] - public Guid Comune { get; set; } + public Guid? Comune { get; set; } [Required(ErrorMessage = "Il CAP è obbigatorio")] public string Cap { get; set; } [Required(ErrorMessage = "La Ragione Sociale è obbigatoria")] @@ -59,6 +59,8 @@ public class IscrizioneEventoViewModel model.EsperienzaConDAC = EsperienzaConDAC; model.PartitaIva = PartitaIva; model.GiornoPresenza = GiornoPresenza.Value; + model.ComuneId = Comune.GetValueOrDefault(); + model.ProvinciaId = Provincia; return model; } @@ -90,7 +92,7 @@ public class IscrizioneEventoViewModel Ruolo = model.Ruolo, RuoloInt = (int?)model.Ruolo, PartitaIva = model.PartitaIva, - GiornoPresenza = model.GiornoPresenza + GiornoPresenza = model.GiornoPresenza, }; }