Fix registrazione

This commit is contained in:
2026-02-06 19:30:48 +01:00
parent ef2c779f83
commit b24dbc8fc3
7 changed files with 83 additions and 46 deletions

View File

@ -48,6 +48,9 @@
</div> </div>
@code { @code {
[SupplyParameterFromQuery]
public string? ReturnUrl { get; set; }
[SupplyParameterFromForm] [SupplyParameterFromForm]
private LoginModel? model { get; set; } private LoginModel? model { get; set; }
@ -56,7 +59,10 @@
[CascadingParameter] [CascadingParameter]
public HttpContext? httpContext { get; set; } public HttpContext? httpContext { get; set; }
protected override void OnInitialized() => model ??= new(); protected override void OnInitialized()
{
model ??= new();
}
/// <summary> /// <summary>
/// Gestisce il login: controlla le credenziali, crea i claim dellutente, /// Gestisce il login: controlla le credenziali, crea i claim dellutente,
@ -87,6 +93,13 @@
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var principal = new ClaimsPrincipal(identity); var principal = new ClaimsPrincipal(identity);
await httpContext.SignInAsync(principal); await httpContext.SignInAsync(principal);
_navManager.NavigateTo("/management"); if (!string.IsNullOrWhiteSpace(ReturnUrl))
{
_navManager.NavigateTo(ReturnUrl, forceLoad: true);
}
else
{
_navManager.NavigateTo("/management");
}
} }
} }

View File

@ -51,20 +51,17 @@
<RadzenDropDown TValue="Guid ?" @bind-Value="@iscrizione.ProvinciaId" Change="@(args => onProvinciaChanged(args))" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona la provincia" <RadzenDropDown TValue="Guid ?" @bind-Value="@iscrizione.ProvinciaId" Change="@(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.ProvinciaId)" />
</div> </div>
<div class="col-4 mb-3"> <div class="col-4 mb-3">
<RadzenFormField Text="CAP" Variant="Variant.Flat" Style="width: 100%;"> <RadzenFormField Text="CAP" Variant="Variant.Flat" Style="width: 100%;">
<RadzenTextBox Style="width: 100%" aria-label="Cap" @bind-Value="@iscrizione.Cap" /> <RadzenTextBox Style="width: 100%" aria-label="Cap" @bind-Value="@iscrizione.Cap" />
</RadzenFormField> </RadzenFormField>
<ValidationMessage For="@(() => iscrizione.Cap)" />
</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 TValue="Guid ?" @bind-Value="@iscrizione.ComuneId" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona il comune" <RadzenDropDown TValue="Guid ?" @bind-Value="@iscrizione.ComuneId" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona il comune"
Data="@comuniList" Size="ButtonSize.Small" /> Data="@comuniList" Size="ButtonSize.Small" />
</RadzenFormField> </RadzenFormField>
<ValidationMessage For="@(() => iscrizione.ComuneId)" />
</div> </div>
</div> </div>
@ -112,7 +109,7 @@
</div> </div>
<div class="row"> <div class="row">
@if (hasCliente) @if (cliente)
{ {
<div class="col-6 mb-3"> <div class="col-6 mb-3">
<RadzenFormField Text="Destinazione" Variant="Variant.Flat" Style="width: 100%;"> <RadzenFormField Text="Destinazione" Variant="Variant.Flat" Style="width: 100%;">
@ -121,7 +118,7 @@
</RadzenFormField> </RadzenFormField>
</div> </div>
} }
<div class=@(hasCliente ? "col-6 mb-3" : "col-12 mb-3")> <div class=@(cliente ? "col-6 mb-3" : "col-12 mb-3")>
<RadzenFormField Text="Note" Variant="Variant.Flat" Style="width: 100%; border: none !important; box-shadow: none !important; background-color: transparent !important;"> <RadzenFormField Text="Note" Variant="Variant.Flat" Style="width: 100%; border: none !important; box-shadow: none !important; background-color: transparent !important;">
<RadzenTextArea @bind-Value="@iscrizione.Note" Style="width: 100%;" Rows="1" /> <RadzenTextArea @bind-Value="@iscrizione.Note" Style="width: 100%;" Rows="1" />
</RadzenFormField> </RadzenFormField>
@ -141,8 +138,7 @@
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<RadzenCheckBox class="form-check-input" @bind-Value="presaVisioneDatiPersonali" Name="presaVisioneDatiPersonali" TValue="bool" /> <RadzenCheckBox class="form-check-input" @bind-Value="presaVisioneDatiPersonali" Name="presaVisioneDatiPersonali" TValue="bool" />
<label class="rz-ms-2" for="presaVisioneDatiPersonali" style="cursor: pointer;"> <label class="rz-ms-2" for="presaVisioneDatiPersonali" style="cursor: pointer;">
Autorizzazione al trattamento dati*<br /> Autorizzazione al trattamento dati*. (<a href="https://www.gruppodac.eu/tutela-e-privacy/" target="_blank">leggi</a>)
I dati forniti saranno utilizzati esclusivamente per linvio del biglietto. (<a href="https://www.gruppodac.eu/tutela-e-privacy/" target="_blank">leggi</a>)
</label> </label>
</div> </div>
</div> </div>
@ -160,7 +156,8 @@
@code { @code {
[Parameter] public InvitoEventoViewModel invito { get; set; } [Parameter] public InvitoEventoViewModel invito { get; set; }
[Parameter] public bool hasCliente { get; set; } [Parameter] public string ReturnUrl { get; set; }
[Parameter] public bool cliente { get; set; }
[Parameter] public Func<object?, IscrizioneEvento, Task>? OnSubmitCompletedAsync { get; set; } [Parameter] public Func<object?, IscrizioneEvento, Task>? OnSubmitCompletedAsync { get; set; }
@ -204,10 +201,10 @@
inizioEvento = evento?.DataDa ?? DateTime.Now.AddDays(-7); inizioEvento = evento?.DataDa ?? DateTime.Now.AddDays(-7);
fineEvento = evento?.DataA ?? DateTime.Now.AddDays(7); fineEvento = evento?.DataA ?? DateTime.Now.AddDays(7);
if (!hasCliente) if (!cliente)
NoCliente(); NoCliente();
else else
HasCliente(); GiaCliente();
} }
/// <summary> /// <summary>
@ -215,26 +212,41 @@
/// </summary> /// </summary>
private async Task onIscrizioneSave() private async Task onIscrizioneSave()
{ {
var userId = await MembershipUtils.GetUserId(_auth); try
var model = new IscrizioneEvento()
{ {
EventoId = invito.EventoId, var userId = await MembershipUtils.GetUserId(_auth);
InvitoEventoId = invito.Id,
ClienteId = invito.ClienteId,
DestinazioneId = iscrizione.DestinazioneId,
TipologiaClienteId = iscrizione.TipologiaClienteId,
//IdUtenteCreazione = userId != Guid.Empty ? userId : null
};
model = iscrizione.Map(model); if (!cliente)
{
if (iscrizione.ProvinciaId.GetValueOrDefault() == Guid.Empty) throw new Exception("La provincia è obbligatoria");
if (string.IsNullOrEmpty(iscrizione.Cap)) throw new Exception("Il CAP è obbligatorio");
if (iscrizione.ComuneId.GetValueOrDefault() == Guid.Empty) throw new Exception("Il comune è obbligatoria");
}
var saved = await _managerService.IscrizioneEventoService.Salva(model); var model = new IscrizioneEvento()
if (OnSubmitCompletedAsync is not null) {
{ EventoId = invito.EventoId,
await OnSubmitCompletedAsync(this, saved); InvitoEventoId = invito.Id,
ClienteId = invito.ClienteId,
DestinazioneId = iscrizione.DestinazioneId,
TipologiaClienteId = iscrizione.TipologiaClienteId,
//IdUtenteCreazione = userId != Guid.Empty ? userId : null
};
model = iscrizione.Map(model);
var saved = await _managerService.IscrizioneEventoService.Salva(model);
if (OnSubmitCompletedAsync is not null)
{
await OnSubmitCompletedAsync(this, saved);
}
var returnUrl = Uri.EscapeDataString(ReturnUrl ?? "/");
_navManager.NavigateTo($"/Grazie?ReturnUrl={returnUrl}");
}
catch (Exception ex)
{
await _dialogService.Alert(ex.Message, "Errore");
} }
_navManager.NavigateTo($"/Grazie");
} }
/// <summary> /// <summary>
@ -260,7 +272,7 @@
} }
public void HasCliente() public void GiaCliente()
{ {
iscrizione.EsperienzaConDAC = "Si"; iscrizione.EsperienzaConDAC = "Si";
} }
@ -293,7 +305,7 @@
/// </summary> /// </summary>
private async Task onCodiceFornitoChanged(string text) private async Task onCodiceFornitoChanged(string text)
{ {
if (!hasCliente) return; if (!cliente) return;
var codiceFornito = text; var codiceFornito = text;
invito.CodiceFornito = codiceFornito; invito.CodiceFornito = codiceFornito;

View File

@ -59,8 +59,18 @@
</style> </style>
@code { @code {
[SupplyParameterFromQuery]
public string? ReturnUrl { get; set; }
private void goToHome() private void goToHome()
{ {
_navManager.NavigateTo("/registrazione"); if (!string.IsNullOrWhiteSpace(ReturnUrl) && ReturnUrl.StartsWith("/"))
{
_navManager.NavigateTo(ReturnUrl);
}
else
{
_navManager.NavigateTo("/registrazione");
}
} }
} }

View File

@ -46,8 +46,7 @@
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<RadzenCheckBox class="form-check-input" @bind-Value="PresaVisioneDatiPersonali" Name="presaVisioneDatiPersonali" TValue="bool"/> <RadzenCheckBox class="form-check-input" @bind-Value="PresaVisioneDatiPersonali" Name="presaVisioneDatiPersonali" TValue="bool"/>
<label class="rz-ms-2" for="presaVisioneDatiPersonali" style="cursor: pointer;"> <label class="rz-ms-2" for="presaVisioneDatiPersonali" style="cursor: pointer;">
Autorizzazione al trattamento dati*<br/> Autorizzazione al trattamento dati* (<a href="https://www.gruppodac.eu/tutela-e-privacy/" target="_blank">leggi</a>)
I dati forniti saranno utilizzati esclusivamente per linvio del biglietto. (<a href="https://www.gruppodac.eu/tutela-e-privacy/" target="_blank">leggi</a>)
</label> </label>
</div> </div>
</div> </div>

View File

@ -16,7 +16,7 @@
@if (showForm) @if (showForm)
{ {
<Component_Registrazione invito="invito" hasCliente="hasCliente" @ref="registrazione" /> <Component_Registrazione invito="invito" cliente="cliente" @ref="registrazione" ReturnUrl="/registrazioneInFiera" />
} }
</div> </div>
@ -28,19 +28,19 @@
private bool showForm { get; set; } = false; private bool showForm { get; set; } = false;
private InvitoEventoViewModel invito { get; set; } = new InvitoEventoViewModel(); private InvitoEventoViewModel invito { get; set; } = new InvitoEventoViewModel();
private Component_Registrazione registrazione { get; set; } = new(); private Component_Registrazione registrazione { get; set; } = new();
private bool hasCliente { get; set; } private bool cliente { get; set; }
private void onClienteToggleChanged(bool value) private void onClienteToggleChanged(bool value)
{ {
if (!value) if (!value)
{ {
hasCliente = false; cliente = false;
registrazione.NoCliente(); registrazione.NoCliente();
} }
else else
{ {
hasCliente = true; cliente = true;
registrazione.HasCliente(); registrazione.GiaCliente();
} }
showCodiceCliente = value; showCodiceCliente = value;

View File

@ -14,9 +14,10 @@
<div class="container my-5 py-3"> <div class="container my-5 py-3">
<Component_Registrazione <Component_Registrazione
invito="invito" invito="invito"
hasCliente="hasCliente" cliente="cliente"
@ref="registrazione" @ref="registrazione"
OnSubmitCompletedAsync="@((sender, model) => onSubmitCompleted(model))"/> OnSubmitCompletedAsync="@((sender, model) => onSubmitCompleted(model))"
ReturnUrl="/registrazione-campagna-socialmedia-dac-expo-tecnocom-2026"/>
</div> </div>
<DacFooter /> <DacFooter />
@ -26,7 +27,7 @@
private bool showForm { get; set; } = false; private bool showForm { get; set; } = false;
private InvitoEventoViewModel invito { get; set; } = new InvitoEventoViewModel(); private InvitoEventoViewModel invito { get; set; } = new InvitoEventoViewModel();
private Component_Registrazione registrazione { get; set; } = new(); private Component_Registrazione registrazione { get; set; } = new();
private bool hasCliente { get; set; } private bool cliente { get; set; }
private async Task onSubmitCompleted(IscrizioneEvento model) private async Task onSubmitCompleted(IscrizioneEvento model)
{ {

View File

@ -29,13 +29,13 @@ public class IscrizioneEventoViewModel
public string Email { get; set; } public string Email { get; set; }
[Required(ErrorMessage = "Il numero di telefono è obbigatorio")] [Required(ErrorMessage = "Il numero di telefono è obbigatorio")]
public string NumeroTelefono { get; set; } public string NumeroTelefono { get; set; }
[Required(ErrorMessage = "La provincia è obbigatoria")] /*[Required(ErrorMessage = "La provincia è obbigatoria")]*/
public Guid? ProvinciaId { get; set; } public Guid? ProvinciaId { get; set; }
public ProvinciaViewModel Provincia { get; set; } public ProvinciaViewModel Provincia { get; set; }
[Required(ErrorMessage = "Il comune è obbigatorio")] /*[Required(ErrorMessage = "Il comune è obbigatorio")]*/
public Guid? ComuneId { get; set; } public Guid? ComuneId { get; set; }
public ComuneIstatViewModel Comune { get; set; } public ComuneIstatViewModel 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")]
public string RagioneSociale { get; set; } public string RagioneSociale { get; set; }
@ -79,8 +79,10 @@ public class IscrizioneEventoViewModel
model.GiornoPresenza = GiornoPresenza.Value; model.GiornoPresenza = GiornoPresenza.Value;
model.Ruolo = (RuoloTipo)RuoloInt; model.Ruolo = (RuoloTipo)RuoloInt;
model.TipologiaClienteId = TipologiaClienteId; model.TipologiaClienteId = TipologiaClienteId;
model.ComuneId = ComuneId.GetValueOrDefault(); if (model.ComuneId.GetValueOrDefault() != Guid.Empty)
model.ProvinciaId = ProvinciaId.GetValueOrDefault(); model.ComuneId = ComuneId.GetValueOrDefault();
if (model.ProvinciaId.GetValueOrDefault() != Guid.Empty)
model.ProvinciaId = ProvinciaId.GetValueOrDefault();
model.AgenteId = AgenteId; model.AgenteId = AgenteId;
model.CapoareaId = CapoareaId; model.CapoareaId = CapoareaId;