- onProvinciaChanged(args))" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona la provincia"
Data="@provList" Size="ButtonSize.Small" />
@@ -51,8 +51,8 @@
-
+
@@ -154,13 +154,13 @@
[SupplyParameterFromForm]
private IscrizioneEventoViewModel iscrizione { get; set; } = new();
- private IEnumerable
comuneList { get; set; }
private IEnumerable destinazioniList { get; set; }
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 bool presaVisionePrivacy { get; set; }
private bool presaVisioneDatiPersonali { get; set; }
@@ -172,7 +172,6 @@
var destinazioniIds = invito.IscrizioniEvento?.Select(x => x.DestinazioneId).ToList() ?? new List();
destinazioniList = (await _managerService.DestinazioneService.RicercaQueryable(filtro: x => x.ClienteId == invito.ClienteId && !destinazioniIds.Any(y => y == x.Id))).Select(x => (DestinazioneViewModel)x).ToList();
- comuneList = new List() { "Brescia" };
esperienzaList = new List() { "Si", "No" };
tipologiaList = (await _managerService.TipologiaClienteService.RicercaQueryable(x => x.Eliminato == false, ordinamento: x => x.OrderBy(y => y.Nome)))
.Select(x => new LookupViewModel(x.Id, x.Nome)).ToList();
@@ -223,4 +222,22 @@
{
destinazioniList = new List() { new DestinazioneViewModel() { RagioneSociale = "--Nessuna" } };
}
+
+ private async Task onProvinciaChanged(ChangeEventArgs args)
+ {
+ Guid parsed;
+ var guidId = Guid.TryParse(args.Value?.ToString(), out parsed);
+ var prov = await _managerService.ProvinciaIstatService.RicercaPer(x => x.Id == parsed);
+
+ if (prov == null)
+ {
+ await _dialogService.Alert("La provincia indicata non è presente", "Errore", new ConfirmOptions() { OkButtonText = "Ok" });
+ return;
+ }
+
+ iscrizione.Provincia = prov.Id;
+
+ comuniList = (await _managerService.ComuneIstatService.RicercaQueryable(x => x.Provincia == prov.Sigla))
+ .Select(x => (ComuneIstatExcelViewModel)x).ToList();
+ }
}
\ No newline at end of file
diff --git a/StandManager/Model/ComuneIstatExcelViewModel.cs b/StandManager/Model/ComuneIstatExcelViewModel.cs
index 842a099..77571cf 100644
--- a/StandManager/Model/ComuneIstatExcelViewModel.cs
+++ b/StandManager/Model/ComuneIstatExcelViewModel.cs
@@ -1,9 +1,14 @@
using ClosedXML.Excel;
+using StandManager.Domain.Entita;
namespace StandManager.Model;
public class ComuneIstatExcelViewModel
{
+ public ComuneIstatExcelViewModel()
+ {
+
+ }
public ComuneIstatExcelViewModel(IXLRangeRow row)
{
Istat = row.Cell(1).GetString();
@@ -14,6 +19,7 @@ public class ComuneIstatExcelViewModel
CodFisco = row.Cell(6).GetString();
}
+ public Guid Id { get; set; }
public string Istat { get; set; }
public string Comune { get; set; }
public string Regione { get; set; }
@@ -21,4 +27,14 @@ public class ComuneIstatExcelViewModel
public string Prefisso { get; set; }
public string CodFisco { get; set; }
+ public static implicit operator ComuneIstatExcelViewModel(ComuneIstat model)
+ {
+ return model == null
+ ? null
+ : new ComuneIstatExcelViewModel
+ {
+ Id = model.Id,
+ Comune = model.Comune
+ };
+ }
}
\ No newline at end of file
diff --git a/StandManager/Model/IscrizioneEventoViewModel.cs b/StandManager/Model/IscrizioneEventoViewModel.cs
index 988ead9..ae7f7e0 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 string Comune { get; set; }
+ public Guid Comune { get; set; }
[Required(ErrorMessage = "Il CAP è obbigatorio")]
public string Cap { get; set; }
[Required(ErrorMessage = "La Ragione Sociale è obbigatoria")]
@@ -54,8 +54,6 @@ public class IscrizioneEventoViewModel
model.Cognome = Cognome;
model.Email = Email;
model.NumeroTelefono = NumeroTelefono;
- /*model.Provincia = Provincia;*/
- model.Comune = Comune;
model.Cap = Cap;
model.RagioneSociale = RagioneSociale;
model.EsperienzaConDAC = EsperienzaConDAC;
@@ -84,7 +82,7 @@ public class IscrizioneEventoViewModel
Email = model.Email,
NumeroTelefono = model.NumeroTelefono,
Provincia = model.Provincia?.Id ?? Guid.Empty,
- Comune = model.Comune,
+ Comune = model.Comune?.Id ?? Guid.Empty,
Cap = model.Cap,
RagioneSociale = model.RagioneSociale,
EsperienzaConDAC = model.EsperienzaConDAC,