GuidComune

This commit is contained in:
2025-12-22 17:01:43 +01:00
parent 8e4daf5f2e
commit 4c6c44ce6f
7 changed files with 1278 additions and 12 deletions

View File

@ -32,7 +32,9 @@ public class IscrizioneEvento : EntitaBase
[ForeignKey(nameof(Provincia))] [ForeignKey(nameof(Provincia))]
public Guid? ProvinciaId { get; set; } public Guid? ProvinciaId { get; set; }
public ProvinciaIstat Provincia { get; set; } public ProvinciaIstat Provincia { get; set; }
public string? Comune { get; set; } [ForeignKey(nameof(Comune))]
public Guid? ComuneId { get; set; }
public ComuneIstat Comune { get; set; }
public string? Cap { get; set; } public string? Cap { get; set; }
public string? RagioneSociale { get; set; } public string? RagioneSociale { get; set; }
[ForeignKey(nameof(TipologiaCliente))] [ForeignKey(nameof(TipologiaCliente))]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,59 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace StandManager.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class GuidComune : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Comune",
table: "IscrizioneEvento");
migrationBuilder.AddColumn<Guid>(
name: "ComuneId",
table: "IscrizioneEvento",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_IscrizioneEvento_ComuneId",
table: "IscrizioneEvento",
column: "ComuneId");
migrationBuilder.AddForeignKey(
name: "FK_IscrizioneEvento_ComuneIstat_ComuneId",
table: "IscrizioneEvento",
column: "ComuneId",
principalTable: "ComuneIstat",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IscrizioneEvento_ComuneIstat_ComuneId",
table: "IscrizioneEvento");
migrationBuilder.DropIndex(
name: "IX_IscrizioneEvento_ComuneId",
table: "IscrizioneEvento");
migrationBuilder.DropColumn(
name: "ComuneId",
table: "IscrizioneEvento");
migrationBuilder.AddColumn<string>(
name: "Comune",
table: "IscrizioneEvento",
type: "nvarchar(max)",
nullable: true);
}
}
}

View File

@ -398,8 +398,8 @@ namespace StandManager.Infrastructure.Migrations
b.Property<string>("Cognome") b.Property<string>("Cognome")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Comune") b.Property<Guid?>("ComuneId")
.HasColumnType("nvarchar(max)"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("DataCreazione") b.Property<DateTime>("DataCreazione")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
@ -471,6 +471,8 @@ namespace StandManager.Infrastructure.Migrations
b.HasIndex("ClienteId"); b.HasIndex("ClienteId");
b.HasIndex("ComuneId");
b.HasIndex("DestinazioneId"); b.HasIndex("DestinazioneId");
b.HasIndex("EventoId"); b.HasIndex("EventoId");
@ -941,6 +943,10 @@ namespace StandManager.Infrastructure.Migrations
.WithMany() .WithMany()
.HasForeignKey("ClienteId"); .HasForeignKey("ClienteId");
b.HasOne("StandManager.Domain.Entita.ComuneIstat", "Comune")
.WithMany()
.HasForeignKey("ComuneId");
b.HasOne("StandManager.Domain.Entita.Destinazione", "Destinazione") b.HasOne("StandManager.Domain.Entita.Destinazione", "Destinazione")
.WithMany() .WithMany()
.HasForeignKey("DestinazioneId"); .HasForeignKey("DestinazioneId");
@ -971,6 +977,8 @@ namespace StandManager.Infrastructure.Migrations
b.Navigation("Cliente"); b.Navigation("Cliente");
b.Navigation("Comune");
b.Navigation("Destinazione"); b.Navigation("Destinazione");
b.Navigation("Evento"); b.Navigation("Evento");

View File

@ -38,7 +38,7 @@
<div class="row"> <div class="row">
<div class="col-4 mb-3"> <div class="col-4 mb-3">
<RadzenFormField Text="Provincia" Variant="Variant.Flat" Style="width: 100%;"> <RadzenFormField Text="Provincia" Variant="Variant.Flat" Style="width: 100%;">
<RadzenDropDown TValue="Guid" @bind-Value="@iscrizione.Provincia" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona la provincia" <RadzenDropDown TValue="Guid" @onchange="(args => onProvinciaChanged(args))" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona la provincia"
Data="@provList" Size="ButtonSize.Small" /> Data="@provList" Size="ButtonSize.Small" />
</RadzenFormField> </RadzenFormField>
<ValidationMessage For="@(() => iscrizione.Provincia)" /> <ValidationMessage For="@(() => iscrizione.Provincia)" />
@ -51,8 +51,8 @@
</div> </div>
<div class="col-4 mb-3"> <div class="col-4 mb-3">
<RadzenFormField Text="Comune" Variant="Variant.Flat" Style="width: 100%;"> <RadzenFormField Text="Comune" Variant="Variant.Flat" Style="width: 100%;">
<RadzenDropDown @bind-Value="@iscrizione.Comune" Style="width: 100%" TextProperty="" Placeholder="Seleziona il comune" <RadzenDropDown TValue="Guid" @bind-Value="@iscrizione.Comune" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona il comune"
Data="@comuneList" Size="ButtonSize.Small" /> Data="@comuniList" Size="ButtonSize.Small" />
</RadzenFormField> </RadzenFormField>
<ValidationMessage For="@(() => iscrizione.Comune)" /> <ValidationMessage For="@(() => iscrizione.Comune)" />
</div> </div>
@ -154,13 +154,13 @@
[SupplyParameterFromForm] [SupplyParameterFromForm]
private IscrizioneEventoViewModel iscrizione { get; set; } = new(); private IscrizioneEventoViewModel iscrizione { get; set; } = new();
private IEnumerable<string> comuneList { get; set; }
private IEnumerable<DestinazioneViewModel> destinazioniList { get; set; } private IEnumerable<DestinazioneViewModel> destinazioniList { get; set; }
private IEnumerable<LookupViewModel<Guid>> tipologiaList { get; set; } private IEnumerable<LookupViewModel<Guid>> tipologiaList { get; set; }
private IEnumerable<string> esperienzaList { get; set; } private IEnumerable<string> esperienzaList { get; set; }
private IEnumerable<LookupViewModel<int>> ruoloList { get; set; } private IEnumerable<LookupViewModel<int>> ruoloList { get; set; }
private List<ProvinciaViewModel> provList { get; set; } private List<ProvinciaViewModel> provList { get; set; }
private List<ComuneIstatExcelViewModel> comuniList { get; set; }
private bool presaVisionePrivacy { get; set; } private bool presaVisionePrivacy { get; set; }
private bool presaVisioneDatiPersonali { get; set; } private bool presaVisioneDatiPersonali { get; set; }
@ -172,7 +172,6 @@
var destinazioniIds = invito.IscrizioniEvento?.Select(x => x.DestinazioneId).ToList() ?? new List<Guid?>(); var destinazioniIds = invito.IscrizioniEvento?.Select(x => x.DestinazioneId).ToList() ?? new List<Guid?>();
destinazioniList = (await _managerService.DestinazioneService.RicercaQueryable(filtro: x => x.ClienteId == invito.ClienteId && !destinazioniIds.Any(y => y == x.Id))).Select(x => (DestinazioneViewModel)x).ToList(); 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<string>() { "Brescia" };
esperienzaList = new List<string>() { "Si", "No" }; esperienzaList = new List<string>() { "Si", "No" };
tipologiaList = (await _managerService.TipologiaClienteService.RicercaQueryable(x => x.Eliminato == false, ordinamento: x => x.OrderBy(y => y.Nome))) tipologiaList = (await _managerService.TipologiaClienteService.RicercaQueryable(x => x.Eliminato == false, ordinamento: x => x.OrderBy(y => y.Nome)))
.Select(x => new LookupViewModel<Guid>(x.Id, x.Nome)).ToList(); .Select(x => new LookupViewModel<Guid>(x.Id, x.Nome)).ToList();
@ -223,4 +222,22 @@
{ {
destinazioniList = new List<DestinazioneViewModel>() { new DestinazioneViewModel() { RagioneSociale = "--Nessuna" } }; destinazioniList = new List<DestinazioneViewModel>() { 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();
}
} }

View File

@ -1,9 +1,14 @@
using ClosedXML.Excel; using ClosedXML.Excel;
using StandManager.Domain.Entita;
namespace StandManager.Model; namespace StandManager.Model;
public class ComuneIstatExcelViewModel public class ComuneIstatExcelViewModel
{ {
public ComuneIstatExcelViewModel()
{
}
public ComuneIstatExcelViewModel(IXLRangeRow row) public ComuneIstatExcelViewModel(IXLRangeRow row)
{ {
Istat = row.Cell(1).GetString(); Istat = row.Cell(1).GetString();
@ -14,6 +19,7 @@ public class ComuneIstatExcelViewModel
CodFisco = row.Cell(6).GetString(); CodFisco = row.Cell(6).GetString();
} }
public Guid Id { get; set; }
public string Istat { get; set; } public string Istat { get; set; }
public string Comune { get; set; } public string Comune { get; set; }
public string Regione { get; set; } public string Regione { get; set; }
@ -21,4 +27,14 @@ public class ComuneIstatExcelViewModel
public string Prefisso { get; set; } public string Prefisso { get; set; }
public string CodFisco { 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
};
}
} }

View File

@ -28,7 +28,7 @@ public class IscrizioneEventoViewModel
[Required(ErrorMessage = "La provincia è obbigatoria")] [Required(ErrorMessage = "La provincia è obbigatoria")]
public Guid Provincia { get; set; } public Guid Provincia { get; set; }
[Required(ErrorMessage = "Il comune è obbigatorio")] [Required(ErrorMessage = "Il comune è obbigatorio")]
public string Comune { get; set; } public Guid Comune { get; set; }
[Required(ErrorMessage = "Il CAP è obbigatorio")] [Required(ErrorMessage = "Il CAP è obbigatorio")]
public string Cap { get; set; } public string Cap { get; set; }
[Required(ErrorMessage = "La Ragione Sociale è obbigatoria")] [Required(ErrorMessage = "La Ragione Sociale è obbigatoria")]
@ -54,8 +54,6 @@ public class IscrizioneEventoViewModel
model.Cognome = Cognome; model.Cognome = Cognome;
model.Email = Email; model.Email = Email;
model.NumeroTelefono = NumeroTelefono; model.NumeroTelefono = NumeroTelefono;
/*model.Provincia = Provincia;*/
model.Comune = Comune;
model.Cap = Cap; model.Cap = Cap;
model.RagioneSociale = RagioneSociale; model.RagioneSociale = RagioneSociale;
model.EsperienzaConDAC = EsperienzaConDAC; model.EsperienzaConDAC = EsperienzaConDAC;
@ -84,7 +82,7 @@ public class IscrizioneEventoViewModel
Email = model.Email, Email = model.Email,
NumeroTelefono = model.NumeroTelefono, NumeroTelefono = model.NumeroTelefono,
Provincia = model.Provincia?.Id ?? Guid.Empty, Provincia = model.Provincia?.Id ?? Guid.Empty,
Comune = model.Comune, Comune = model.Comune?.Id ?? Guid.Empty,
Cap = model.Cap, Cap = model.Cap,
RagioneSociale = model.RagioneSociale, RagioneSociale = model.RagioneSociale,
EsperienzaConDAC = model.EsperienzaConDAC, EsperienzaConDAC = model.EsperienzaConDAC,