Fix registrazione
This commit is contained in:
@ -48,6 +48,9 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[SupplyParameterFromQuery]
|
||||
public string? ReturnUrl { get; set; }
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private LoginModel? model { get; set; }
|
||||
|
||||
@ -56,7 +59,10 @@
|
||||
[CascadingParameter]
|
||||
public HttpContext? httpContext { get; set; }
|
||||
|
||||
protected override void OnInitialized() => model ??= new();
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
model ??= new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gestisce il login: controlla le credenziali, crea i claim dell’utente,
|
||||
@ -87,6 +93,13 @@
|
||||
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
var principal = new ClaimsPrincipal(identity);
|
||||
await httpContext.SignInAsync(principal);
|
||||
_navManager.NavigateTo("/management");
|
||||
if (!string.IsNullOrWhiteSpace(ReturnUrl))
|
||||
{
|
||||
_navManager.NavigateTo(ReturnUrl, forceLoad: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_navManager.NavigateTo("/management");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
Data="@provList" Size="ButtonSize.Small" />
|
||||
</RadzenFormField>
|
||||
<ValidationMessage For="@(() => iscrizione.ProvinciaId)" />
|
||||
</div>
|
||||
<div class="col-4 mb-3">
|
||||
<RadzenFormField Text="CAP" Variant="Variant.Flat" Style="width: 100%;">
|
||||
<RadzenTextBox Style="width: 100%" aria-label="Cap" @bind-Value="@iscrizione.Cap" />
|
||||
</RadzenFormField>
|
||||
<ValidationMessage For="@(() => iscrizione.Cap)" />
|
||||
</div>
|
||||
<div class="col-4 mb-3">
|
||||
<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"
|
||||
Data="@comuniList" Size="ButtonSize.Small" />
|
||||
</RadzenFormField>
|
||||
<ValidationMessage For="@(() => iscrizione.ComuneId)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -112,7 +109,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@if (hasCliente)
|
||||
@if (cliente)
|
||||
{
|
||||
<div class="col-6 mb-3">
|
||||
<RadzenFormField Text="Destinazione" Variant="Variant.Flat" Style="width: 100%;">
|
||||
@ -121,7 +118,7 @@
|
||||
</RadzenFormField>
|
||||
</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;">
|
||||
<RadzenTextArea @bind-Value="@iscrizione.Note" Style="width: 100%;" Rows="1" />
|
||||
</RadzenFormField>
|
||||
@ -141,8 +138,7 @@
|
||||
<div class="d-flex align-items-center">
|
||||
<RadzenCheckBox class="form-check-input" @bind-Value="presaVisioneDatiPersonali" Name="presaVisioneDatiPersonali" TValue="bool" />
|
||||
<label class="rz-ms-2" for="presaVisioneDatiPersonali" style="cursor: pointer;">
|
||||
Autorizzazione al trattamento dati*<br />
|
||||
I dati forniti saranno utilizzati esclusivamente per l’invio del biglietto. (<a href="https://www.gruppodac.eu/tutela-e-privacy/" target="_blank">leggi</a>)
|
||||
Autorizzazione al trattamento dati*. (<a href="https://www.gruppodac.eu/tutela-e-privacy/" target="_blank">leggi</a>)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -160,7 +156,8 @@
|
||||
|
||||
@code {
|
||||
[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; }
|
||||
|
||||
@ -204,10 +201,10 @@
|
||||
inizioEvento = evento?.DataDa ?? DateTime.Now.AddDays(-7);
|
||||
fineEvento = evento?.DataA ?? DateTime.Now.AddDays(7);
|
||||
|
||||
if (!hasCliente)
|
||||
if (!cliente)
|
||||
NoCliente();
|
||||
else
|
||||
HasCliente();
|
||||
GiaCliente();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -215,26 +212,41 @@
|
||||
/// </summary>
|
||||
private async Task onIscrizioneSave()
|
||||
{
|
||||
var userId = await MembershipUtils.GetUserId(_auth);
|
||||
|
||||
var model = new IscrizioneEvento()
|
||||
try
|
||||
{
|
||||
EventoId = invito.EventoId,
|
||||
InvitoEventoId = invito.Id,
|
||||
ClienteId = invito.ClienteId,
|
||||
DestinazioneId = iscrizione.DestinazioneId,
|
||||
TipologiaClienteId = iscrizione.TipologiaClienteId,
|
||||
//IdUtenteCreazione = userId != Guid.Empty ? userId : null
|
||||
};
|
||||
var userId = await MembershipUtils.GetUserId(_auth);
|
||||
|
||||
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);
|
||||
if (OnSubmitCompletedAsync is not null)
|
||||
{
|
||||
await OnSubmitCompletedAsync(this, saved);
|
||||
var model = new IscrizioneEvento()
|
||||
{
|
||||
EventoId = invito.EventoId,
|
||||
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>
|
||||
@ -260,7 +272,7 @@
|
||||
|
||||
}
|
||||
|
||||
public void HasCliente()
|
||||
public void GiaCliente()
|
||||
{
|
||||
iscrizione.EsperienzaConDAC = "Si";
|
||||
}
|
||||
@ -293,7 +305,7 @@
|
||||
/// </summary>
|
||||
private async Task onCodiceFornitoChanged(string text)
|
||||
{
|
||||
if (!hasCliente) return;
|
||||
if (!cliente) return;
|
||||
|
||||
var codiceFornito = text;
|
||||
invito.CodiceFornito = codiceFornito;
|
||||
|
||||
@ -59,8 +59,18 @@
|
||||
</style>
|
||||
|
||||
@code {
|
||||
[SupplyParameterFromQuery]
|
||||
public string? ReturnUrl { get; set; }
|
||||
|
||||
private void goToHome()
|
||||
{
|
||||
_navManager.NavigateTo("/registrazione");
|
||||
if (!string.IsNullOrWhiteSpace(ReturnUrl) && ReturnUrl.StartsWith("/"))
|
||||
{
|
||||
_navManager.NavigateTo(ReturnUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
_navManager.NavigateTo("/registrazione");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -46,8 +46,7 @@
|
||||
<div class="d-flex align-items-center">
|
||||
<RadzenCheckBox class="form-check-input" @bind-Value="PresaVisioneDatiPersonali" Name="presaVisioneDatiPersonali" TValue="bool"/>
|
||||
<label class="rz-ms-2" for="presaVisioneDatiPersonali" style="cursor: pointer;">
|
||||
Autorizzazione al trattamento dati*<br/>
|
||||
I dati forniti saranno utilizzati esclusivamente per l’invio del biglietto. (<a href="https://www.gruppodac.eu/tutela-e-privacy/" target="_blank">leggi</a>)
|
||||
Autorizzazione al trattamento dati* (<a href="https://www.gruppodac.eu/tutela-e-privacy/" target="_blank">leggi</a>)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
@if (showForm)
|
||||
{
|
||||
<Component_Registrazione invito="invito" hasCliente="hasCliente" @ref="registrazione" />
|
||||
<Component_Registrazione invito="invito" cliente="cliente" @ref="registrazione" ReturnUrl="/registrazioneInFiera" />
|
||||
}
|
||||
|
||||
</div>
|
||||
@ -28,19 +28,19 @@
|
||||
private bool showForm { get; set; } = false;
|
||||
private InvitoEventoViewModel invito { get; set; } = new InvitoEventoViewModel();
|
||||
private Component_Registrazione registrazione { get; set; } = new();
|
||||
private bool hasCliente { get; set; }
|
||||
private bool cliente { get; set; }
|
||||
|
||||
private void onClienteToggleChanged(bool value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
hasCliente = false;
|
||||
cliente = false;
|
||||
registrazione.NoCliente();
|
||||
}
|
||||
else
|
||||
{
|
||||
hasCliente = true;
|
||||
registrazione.HasCliente();
|
||||
cliente = true;
|
||||
registrazione.GiaCliente();
|
||||
}
|
||||
|
||||
showCodiceCliente = value;
|
||||
|
||||
@ -14,9 +14,10 @@
|
||||
<div class="container my-5 py-3">
|
||||
<Component_Registrazione
|
||||
invito="invito"
|
||||
hasCliente="hasCliente"
|
||||
cliente="cliente"
|
||||
@ref="registrazione"
|
||||
OnSubmitCompletedAsync="@((sender, model) => onSubmitCompleted(model))"/>
|
||||
OnSubmitCompletedAsync="@((sender, model) => onSubmitCompleted(model))"
|
||||
ReturnUrl="/registrazione-campagna-socialmedia-dac-expo-tecnocom-2026"/>
|
||||
</div>
|
||||
|
||||
<DacFooter />
|
||||
@ -26,7 +27,7 @@
|
||||
private bool showForm { get; set; } = false;
|
||||
private InvitoEventoViewModel invito { get; set; } = new InvitoEventoViewModel();
|
||||
private Component_Registrazione registrazione { get; set; } = new();
|
||||
private bool hasCliente { get; set; }
|
||||
private bool cliente { get; set; }
|
||||
|
||||
private async Task onSubmitCompleted(IscrizioneEvento model)
|
||||
{
|
||||
|
||||
@ -29,13 +29,13 @@ public class IscrizioneEventoViewModel
|
||||
public string Email { get; set; }
|
||||
[Required(ErrorMessage = "Il numero di telefono è obbigatorio")]
|
||||
public string NumeroTelefono { get; set; }
|
||||
[Required(ErrorMessage = "La provincia è obbigatoria")]
|
||||
/*[Required(ErrorMessage = "La provincia è obbigatoria")]*/
|
||||
public Guid? ProvinciaId { get; set; }
|
||||
public ProvinciaViewModel Provincia { get; set; }
|
||||
[Required(ErrorMessage = "Il comune è obbigatorio")]
|
||||
/*[Required(ErrorMessage = "Il comune è obbigatorio")]*/
|
||||
public Guid? ComuneId { get; set; }
|
||||
public ComuneIstatViewModel Comune { get; set; }
|
||||
[Required(ErrorMessage = "Il CAP è obbigatorio")]
|
||||
/*[Required(ErrorMessage = "Il CAP è obbigatorio")]*/
|
||||
public string Cap { get; set; }
|
||||
[Required(ErrorMessage = "La Ragione Sociale è obbigatoria")]
|
||||
public string RagioneSociale { get; set; }
|
||||
@ -79,8 +79,10 @@ public class IscrizioneEventoViewModel
|
||||
model.GiornoPresenza = GiornoPresenza.Value;
|
||||
model.Ruolo = (RuoloTipo)RuoloInt;
|
||||
model.TipologiaClienteId = TipologiaClienteId;
|
||||
model.ComuneId = ComuneId.GetValueOrDefault();
|
||||
model.ProvinciaId = ProvinciaId.GetValueOrDefault();
|
||||
if (model.ComuneId.GetValueOrDefault() != Guid.Empty)
|
||||
model.ComuneId = ComuneId.GetValueOrDefault();
|
||||
if (model.ProvinciaId.GetValueOrDefault() != Guid.Empty)
|
||||
model.ProvinciaId = ProvinciaId.GetValueOrDefault();
|
||||
model.AgenteId = AgenteId;
|
||||
model.CapoareaId = CapoareaId;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user