- Gestione Iscrizioni in management
- PartitaIVA in Component_Registrazione - Flag "Da verificare" a DB
This commit is contained in:
@ -44,6 +44,14 @@ public class IscrizioneEvento : EntitaBase
|
||||
public RuoloTipo Ruolo { get; set; }
|
||||
public string? PartitaIva { get; set; }
|
||||
public DateTime GiornoPresenza { get; set; }
|
||||
|
||||
[ForeignKey(nameof(Agente))]
|
||||
public Guid? AgenteId { get; set; }
|
||||
public Utente Agente { get; set; }
|
||||
|
||||
[ForeignKey(nameof(Capoarea))]
|
||||
public Guid? CapoareaId { get; set; }
|
||||
public Utente Capoarea { get; set; }
|
||||
}
|
||||
|
||||
public enum RuoloTipo
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using StandManager.Domain.Entita.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace StandManager.Domain.Entita;
|
||||
|
||||
@ -6,4 +7,9 @@ public class ProvinciaIstat : EntitaBase
|
||||
{
|
||||
public string Sigla { get; set; }
|
||||
public string Provincia { get; set; }
|
||||
|
||||
public bool CapoareaDaVerificare { get; set; }
|
||||
|
||||
[InverseProperty(nameof(Utente.ProvinciaIstat))]
|
||||
public List<Utente> UtentiList { get; set; }
|
||||
}
|
||||
@ -25,6 +25,10 @@ public class Utente : EntitaBase
|
||||
public Guid? CapoareaId { get; set; }
|
||||
public Utente Capoarea { get; set; }
|
||||
public bool IsCapoarea { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ProvinciaIstat))]
|
||||
public Guid? ProvinciaIstatId { get; set; }
|
||||
public ProvinciaIstat ProvinciaIstat { get; set; }
|
||||
public string Info => $"{Nome} {Cognome}";
|
||||
|
||||
public override string ToString()
|
||||
|
||||
1316
StandManager.Infrastructure/Migrations/20260204162205_CapiareaAgentiInIscrizioneEvento.Designer.cs
generated
Normal file
1316
StandManager.Infrastructure/Migrations/20260204162205_CapiareaAgentiInIscrizioneEvento.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace StandManager.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class CapiareaAgentiInIscrizioneEvento : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ProvinciaIstatId",
|
||||
table: "Utente",
|
||||
type: "uniqueidentifier",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "AgenteId",
|
||||
table: "IscrizioneEvento",
|
||||
type: "uniqueidentifier",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "CapoareaId",
|
||||
table: "IscrizioneEvento",
|
||||
type: "uniqueidentifier",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Utente_ProvinciaIstatId",
|
||||
table: "Utente",
|
||||
column: "ProvinciaIstatId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_IscrizioneEvento_AgenteId",
|
||||
table: "IscrizioneEvento",
|
||||
column: "AgenteId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_IscrizioneEvento_CapoareaId",
|
||||
table: "IscrizioneEvento",
|
||||
column: "CapoareaId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_IscrizioneEvento_Utente_AgenteId",
|
||||
table: "IscrizioneEvento",
|
||||
column: "AgenteId",
|
||||
principalTable: "Utente",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_IscrizioneEvento_Utente_CapoareaId",
|
||||
table: "IscrizioneEvento",
|
||||
column: "CapoareaId",
|
||||
principalTable: "Utente",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Utente_Province_ProvinciaIstatId",
|
||||
table: "Utente",
|
||||
column: "ProvinciaIstatId",
|
||||
principalTable: "Province",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_IscrizioneEvento_Utente_AgenteId",
|
||||
table: "IscrizioneEvento");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_IscrizioneEvento_Utente_CapoareaId",
|
||||
table: "IscrizioneEvento");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Utente_Province_ProvinciaIstatId",
|
||||
table: "Utente");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Utente_ProvinciaIstatId",
|
||||
table: "Utente");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_IscrizioneEvento_AgenteId",
|
||||
table: "IscrizioneEvento");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_IscrizioneEvento_CapoareaId",
|
||||
table: "IscrizioneEvento");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProvinciaIstatId",
|
||||
table: "Utente");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AgenteId",
|
||||
table: "IscrizioneEvento");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CapoareaId",
|
||||
table: "IscrizioneEvento");
|
||||
}
|
||||
}
|
||||
}
|
||||
1319
StandManager.Infrastructure/Migrations/20260205095709_CapoareaDaVerificareInProvincia.Designer.cs
generated
Normal file
1319
StandManager.Infrastructure/Migrations/20260205095709_CapoareaDaVerificareInProvincia.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace StandManager.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class CapoareaDaVerificareInProvincia : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "CapoareaDaVerificare",
|
||||
table: "Province",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CapoareaDaVerificare",
|
||||
table: "Province");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -407,9 +407,15 @@ namespace StandManager.Infrastructure.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("AgenteId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Cap")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid?>("CapoareaId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("ClienteId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
@ -487,6 +493,10 @@ namespace StandManager.Infrastructure.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AgenteId");
|
||||
|
||||
b.HasIndex("CapoareaId");
|
||||
|
||||
b.HasIndex("ClienteId");
|
||||
|
||||
b.HasIndex("ComuneId");
|
||||
@ -608,6 +618,9 @@ namespace StandManager.Infrastructure.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<bool>("CapoareaDaVerificare")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime>("DataCreazione")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
@ -849,6 +862,9 @@ namespace StandManager.Infrastructure.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid?>("ProvinciaIstatId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("RuoloId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
@ -864,6 +880,8 @@ namespace StandManager.Infrastructure.Migrations
|
||||
|
||||
b.HasIndex("IdUtenteModifica");
|
||||
|
||||
b.HasIndex("ProvinciaIstatId");
|
||||
|
||||
b.HasIndex("RuoloId");
|
||||
|
||||
b.ToTable("Utente");
|
||||
@ -1029,6 +1047,14 @@ namespace StandManager.Infrastructure.Migrations
|
||||
|
||||
modelBuilder.Entity("StandManager.Domain.Entita.IscrizioneEvento", b =>
|
||||
{
|
||||
b.HasOne("StandManager.Domain.Entita.Utente", "Agente")
|
||||
.WithMany()
|
||||
.HasForeignKey("AgenteId");
|
||||
|
||||
b.HasOne("StandManager.Domain.Entita.Utente", "Capoarea")
|
||||
.WithMany()
|
||||
.HasForeignKey("CapoareaId");
|
||||
|
||||
b.HasOne("StandManager.Domain.Entita.Cliente", "Cliente")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClienteId");
|
||||
@ -1065,6 +1091,10 @@ namespace StandManager.Infrastructure.Migrations
|
||||
.WithMany()
|
||||
.HasForeignKey("TipologiaClienteId");
|
||||
|
||||
b.Navigation("Agente");
|
||||
|
||||
b.Navigation("Capoarea");
|
||||
|
||||
b.Navigation("Cliente");
|
||||
|
||||
b.Navigation("Comune");
|
||||
@ -1223,12 +1253,18 @@ namespace StandManager.Infrastructure.Migrations
|
||||
.WithMany()
|
||||
.HasForeignKey("IdUtenteModifica");
|
||||
|
||||
b.HasOne("StandManager.Domain.Entita.ProvinciaIstat", "ProvinciaIstat")
|
||||
.WithMany("UtentiList")
|
||||
.HasForeignKey("ProvinciaIstatId");
|
||||
|
||||
b.HasOne("StandManager.Domain.Entita.Ruolo", "Ruolo")
|
||||
.WithMany("Utenti")
|
||||
.HasForeignKey("RuoloId");
|
||||
|
||||
b.Navigation("Capoarea");
|
||||
|
||||
b.Navigation("ProvinciaIstat");
|
||||
|
||||
b.Navigation("Ruolo");
|
||||
|
||||
b.Navigation("UtenteCreazione");
|
||||
@ -1258,6 +1294,11 @@ namespace StandManager.Infrastructure.Migrations
|
||||
b.Navigation("IscrizioniEvento");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("StandManager.Domain.Entita.ProvinciaIstat", b =>
|
||||
{
|
||||
b.Navigation("UtentiList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("StandManager.Domain.Entita.Ruolo", b =>
|
||||
{
|
||||
b.Navigation("Permessi");
|
||||
|
||||
@ -1,10 +1,20 @@
|
||||
@using StandManager.Model
|
||||
@using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<EditForm Model="iscrizione" OnValidSubmit="onIscrizioneSave" FormName="iscrizioneForm">
|
||||
<DataAnnotationsValidator />
|
||||
|
||||
<div class="col-12">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
<RadzenFormField Text="Codice cliente o Partita IVA" Variant="Variant.Flat" Style="width: 100%;">
|
||||
<RadzenTextBox Style="width: 100%" aria-label="Codice cliente o Partita IVA" @bind-Value="@iscrizione.PartitaIva" Change="@(args => onCodiceFornitoChanged(args))" />
|
||||
</RadzenFormField>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6 mb-3">
|
||||
<RadzenFormField Text="Nome" Variant="Variant.Flat" Style="width: 100%;">
|
||||
@ -38,10 +48,10 @@
|
||||
<div class="row">
|
||||
<div class="col-4 mb-3">
|
||||
<RadzenFormField Text="Provincia" Variant="Variant.Flat" Style="width: 100%;">
|
||||
<RadzenDropDown TValue="Guid ?" @bind-bind-Value="@iscrizione.Provincia" Change="@(args => onProvinciaChanged(args))" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona la provincia"
|
||||
<RadzenDropDown TValue="Guid ?" @bind-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.Provincia)" />
|
||||
<ValidationMessage For="@(() => iscrizione.ProvinciaId)" />
|
||||
</div>
|
||||
<div class="col-4 mb-3">
|
||||
<RadzenFormField Text="CAP" Variant="Variant.Flat" Style="width: 100%;">
|
||||
@ -51,10 +61,10 @@
|
||||
</div>
|
||||
<div class="col-4 mb-3">
|
||||
<RadzenFormField Text="Comune" Variant="Variant.Flat" Style="width: 100%;">
|
||||
<RadzenDropDown TValue="Guid ?" @bind-Value="@iscrizione.Comune" 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" />
|
||||
</RadzenFormField>
|
||||
<ValidationMessage For="@(() => iscrizione.Comune)" />
|
||||
<ValidationMessage For="@(() => iscrizione.ComuneId)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -208,12 +218,6 @@
|
||||
IdUtenteCreazione = userId != Guid.Empty ? userId : null
|
||||
};
|
||||
|
||||
/*if (invito.EventoId != Guid.Empty && iscrizione.DestinazioneId == Guid.Empty)
|
||||
{
|
||||
_dialogService.Alert("Selezionare una destinazione valida.", "Attenzione");
|
||||
return;
|
||||
}*/
|
||||
|
||||
model = iscrizione.Map(model);
|
||||
|
||||
var saved = await _managerService.IscrizioneEventoService.Salva(model);
|
||||
@ -260,10 +264,35 @@
|
||||
return;
|
||||
}
|
||||
|
||||
iscrizione.Provincia = prov.Id;
|
||||
iscrizione.Comune = null;
|
||||
iscrizione.ProvinciaId = prov.Id;
|
||||
iscrizione.ComuneId = null;
|
||||
|
||||
comuniList = (await _managerService.ComuneIstatService.RicercaQueryable(x => x.Provincia == prov.Sigla))
|
||||
.Select(x => (ComuneIstatViewModel)x).ToList();
|
||||
}
|
||||
|
||||
private async Task onCodiceFornitoChanged(string text)
|
||||
{
|
||||
if (!hasCliente) return;
|
||||
|
||||
var codiceFornito = text;
|
||||
invito.CodiceFornito = codiceFornito;
|
||||
|
||||
var destinazione = (await _managerService.DestinazioneService.RicercaPer(
|
||||
x => x.PartitaIva == codiceFornito || x.CodiceFiscale == codiceFornito || x.Rid == codiceFornito || x.Cliente.Rid == codiceFornito,
|
||||
includi: x => x.Include(y => y.Cliente)));
|
||||
|
||||
if (destinazione == null || string.IsNullOrEmpty(text))
|
||||
{
|
||||
await _dialogService.Alert("Non è stato trovato il clente (Codice cliente/Partita IVA non presente)", "Errore", new ConfirmOptions() { OkButtonText = "Ok" });
|
||||
}
|
||||
else
|
||||
{
|
||||
invito.ClienteId = destinazione.ClienteId;
|
||||
invito.DestinazioneId = destinazione.Id;
|
||||
invito.CodiceFornito = codiceFornito;
|
||||
invito.RagioneSociale = destinazione.Cliente?.RagioneSociale ?? string.Empty;
|
||||
await SetDatiCliente();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,7 +196,7 @@
|
||||
var idRuolo = await MembershipUtils.GetRoleId(auth);
|
||||
var ruolo = await _managerService.RuoloService.RicercaPer(
|
||||
x => x.Id == idRuolo && x.Permessi.Any(y => y.Feature.Type == FeatureType.Capoarea || y.Feature.Type == FeatureType.AdminGlobal),
|
||||
includi:x => x.Include(y => y.Permessi).ThenInclude(z => z.Feature));
|
||||
includi: x => x.Include(y => y.Permessi).ThenInclude(z => z.Feature));
|
||||
|
||||
isAdmin = ruolo?.Permessi.Where(x => x.Eliminato == false)?.Any(x => x.Feature.Type == FeatureType.AdminGlobal) ?? false;
|
||||
|
||||
|
||||
@ -22,16 +22,17 @@
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<RadzenDataGrid @ref="iscrizioniGrid" AllowFiltering="true" AllowColumnResize="true" AllowAlternatingRows="false" FilterMode="FilterMode.CheckBoxList" AllowSorting="true" PageSize="25"
|
||||
AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Left" ShowPagingSummary="true"
|
||||
AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Left" ShowPagingSummary="true" RowRender="@(RowRender)"
|
||||
Data="@iscrizioni" LogicalFilterOperator="LogicalFilterOperator.Or" SelectionMode="DataGridSelectionMode.Single">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn Property="@nameof(IscrizioneEventoViewModel.RagioneSociale)" Title="Ragione sociale" Width="250px" />
|
||||
<RadzenDataGridColumn Property="@nameof(IscrizioneEventoViewModel.PartitaIva)" Title="Partita IVA" Width="250px" />
|
||||
<RadzenDataGridColumn Property="@nameof(IscrizioneEventoViewModel.GiornoPresenza)" Title="Giorno presenza" Width="250px" FormatString="{0:dd/MM/yyyy}" />
|
||||
|
||||
<RadzenDataGridColumn Context="cliente" Filterable="false" Sortable="false" TextAlign="TextAlign.Right" Width="250px">
|
||||
<Template Context="cliente">
|
||||
<RadzenButton Icon="edit" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Medium" class="rz-my-1 rz-ms-1" Click="@(args => EditRow(cliente))" @onclick:stopPropagation="true" />
|
||||
<RadzenButton Icon="delete" ButtonStyle="ButtonStyle.Danger" Variant="Variant.Flat" Size="ButtonSize.Medium" Shade="Shade.Lighter" class="rz-my-1 rz-ms-1" Click="@(args => DeleteRow(cliente))" @onclick:stopPropagation="true" />
|
||||
<RadzenDataGridColumn Context="iscrizioni" Filterable="false" Sortable="false" TextAlign="TextAlign.Right" Width="250px">
|
||||
<Template Context="iscrizioni">
|
||||
<RadzenButton Icon="edit" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Medium" class="rz-my-1 rz-ms-1" Click="@(args => EditRow(iscrizioni))" @onclick:stopPropagation="true" />
|
||||
<RadzenButton Icon="delete" ButtonStyle="ButtonStyle.Danger" Variant="Variant.Flat" Size="ButtonSize.Medium" Shade="Shade.Lighter" class="rz-my-1 rz-ms-1" Click="@(args => DeleteRow(iscrizioni))" @onclick:stopPropagation="true" />
|
||||
</Template>
|
||||
</RadzenDataGridColumn>
|
||||
</Columns>
|
||||
@ -55,11 +56,17 @@
|
||||
|
||||
iscrizioni = (await _managerService.IscrizioneEventoService.RicercaQueryable(
|
||||
x => x.Eliminato == false,
|
||||
includi:x => x.Include(y => y.Cliente).Include(y => y.Evento).Include(y => y.InvitoEvento),
|
||||
includi:x => x.Include(x => x.Provincia).Include(x => x.Comune).Include(y => y.Cliente).Include(y => y.Evento).Include(y => y.InvitoEvento),
|
||||
ordinamento: x => x.OrderBy(y => y.RagioneSociale)))
|
||||
.Select(x => (IscrizioneEventoViewModel)x).ToList();
|
||||
}
|
||||
|
||||
private void RowRender(RowRenderEventArgs<IscrizioneEventoViewModel> args)
|
||||
{
|
||||
if (args.Data.Provincia?.CapoareaDaVerificare == true && (args.Data.CapoareaId.GetValueOrDefault() == Guid.Empty))
|
||||
args.Attributes.Add("style", "background-color: var(--tblr-red-lt);");
|
||||
}
|
||||
|
||||
private async Task EditRow(IscrizioneEventoViewModel iscrizioneEvento)
|
||||
{
|
||||
_navManager.NavigateTo($"/management/Iscrizioni/Modifica/{iscrizioneEvento.Id}");
|
||||
@ -73,7 +80,7 @@
|
||||
{
|
||||
await _managerService.IscrizioneEventoService.Elimina(iscrizioneEvento.Id, await MembershipUtils.GetUserId(auth));
|
||||
iscrizioni = (await _managerService.IscrizioneEventoService.RicercaQueryable(
|
||||
x => x.Eliminato == false, ordinamento: x => x.OrderBy(y => y.RagioneSociale)))
|
||||
x => x.Eliminato == false, includi: x => x.Include(x => x.Provincia).Include(x => x.Comune).Include(y => y.Cliente).Include(y => y.Evento).Include(y => y.InvitoEvento), ordinamento: x => x.OrderBy(y => y.RagioneSociale)))
|
||||
.Select(x => (IscrizioneEventoViewModel)x).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
312
StandManager/Components/Pages/Management/Iscrizioni_Edit.razor
Normal file
312
StandManager/Components/Pages/Management/Iscrizioni_Edit.razor
Normal file
@ -0,0 +1,312 @@
|
||||
@attribute [Authorize]
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@page "/management/Iscrizioni/Modifica"
|
||||
@page "/management/Iscrizioni/Modifica/{IscrizioneId:guid}"
|
||||
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using StandManager.Model
|
||||
|
||||
@inject AuthenticationStateProvider auth
|
||||
|
||||
<PageTitle>@pageTitle</PageTitle>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<!-- BEGIN PAGE HEADER -->
|
||||
<div class="page-header d-print-none" aria-label="Page header">
|
||||
<div class="container-xl">
|
||||
<div class="row g-2 align-items-center">
|
||||
<div class="col">
|
||||
<h2 class="page-title">@pageTitle</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END PAGE HEADER -->
|
||||
<!-- BEGIN PAGE BODY -->
|
||||
<div class="page-body">
|
||||
<div class="container-xl">
|
||||
<div class="row row-cards">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Anagrafica
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row g-5">
|
||||
<EditForm Model="iscrizione" OnValidSubmit="onIscrizioneSave" FormName="editIscrizioneForm">
|
||||
<DataAnnotationsValidator />
|
||||
|
||||
<div class="col-12">
|
||||
<div class="row">
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Nome</RadzenText>
|
||||
<RadzenTextBox Style="width: 100%" aria-label="Nome" @bind-Value="@iscrizione.Nome" />
|
||||
<ValidationMessage For="@(() => iscrizione.RagioneSociale)" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Cognome</RadzenText>
|
||||
<RadzenTextBox Style="width: 100%" aria-label="Cognome" @bind-Value="@iscrizione.Cognome" />
|
||||
<ValidationMessage For="@(() => iscrizione.PartitaIva)" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Email</RadzenText>
|
||||
<RadzenTextBox Style="width: 100%" aria-label="Email" @bind-Value="@iscrizione.Email" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Numero di Telefono</RadzenText>
|
||||
<RadzenTextBox Style="width: 100%" aria-label="NumeroTelefono" @bind-Value="@iscrizione.NumeroTelefono" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Provincia</RadzenText>
|
||||
<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" />
|
||||
<ValidationMessage For="@(() => iscrizione.ProvinciaId)" />
|
||||
</div>
|
||||
<div class="col-4 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">CAP</RadzenText>
|
||||
<RadzenTextBox Style="width: 100%" aria-label="Cap" @bind-Value="@iscrizione.Cap" />
|
||||
<ValidationMessage For="@(() => iscrizione.Cap)" />
|
||||
</div>
|
||||
<div class="col-4 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Comune</RadzenText>
|
||||
<RadzenDropDown TValue="Guid ?" @bind-Value="@iscrizione.ComuneId" Style="width: 100%" TextProperty="Info" ValueProperty="Id" Placeholder="Seleziona il comune"
|
||||
Data="@comuniList" Size="ButtonSize.Small" />
|
||||
<ValidationMessage For="@(() => iscrizione.ComuneId)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Ragione Sociale</RadzenText>
|
||||
<RadzenTextBox Style="width: 100%" aria-label="RagioneSociale" @bind-Value="@iscrizione.RagioneSociale" />
|
||||
<ValidationMessage For="@(() => iscrizione.RagioneSociale)" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Partita Iva</RadzenText>
|
||||
<RadzenTextBox Style="width: 100%" aria-label="PartitaIVA" @bind-Value="@iscrizione.PartitaIva" />
|
||||
<ValidationMessage For="@(() => iscrizione.PartitaIva)" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Tipologia Cliente</RadzenText>
|
||||
<RadzenDropDown @bind-Value="@iscrizione.TipologiaClienteId" TValue="Guid ?" Style="width: 100%" TextProperty="Description" ValueProperty="Key" Placeholder="Seleziona la tipologia"
|
||||
Data="@tipologiaList" Size="ButtonSize.Small" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Ha già avuto esperienza con DAC?</RadzenText>
|
||||
<RadzenDropDown @bind-Value="@iscrizione.EsperienzaConDAC" Style="width: 100%" TextProperty="" Placeholder="Scegli dal menù"
|
||||
Data="@esperienzaList" Size="ButtonSize.Small" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Destinazione</RadzenText>
|
||||
<RadzenDropDown @bind-Value="@iscrizione.DestinazioneId" TValue="Guid ?" Style="width: 100%" ValueProperty="Id" TextProperty="Info" Placeholder="Seleziona la destinazione"
|
||||
Data="@destinazioniList" Size="ButtonSize.Small" Disabled="@(!destinazioniList.Any(x => x.Id == iscrizione.DestinazioneId))" />
|
||||
<ValidationMessage For="@(() => iscrizione.RagioneSociale)" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Note</RadzenText>
|
||||
<RadzenTextArea @bind-Value="@iscrizione.Note" Style="width: 100%;" Rows="1" />
|
||||
<ValidationMessage For="@(() => iscrizione.PartitaIva)" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Ruolo</RadzenText>
|
||||
<RadzenDropDown @bind-Value="@iscrizione.RuoloInt" TValue="int?" Style="width: 100%" TextProperty="Description" ValueProperty="Key" Placeholder="Seleziona il ruolo"
|
||||
Data="@ruoloList" Size="ButtonSize.Small" />
|
||||
</div>
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Giorno presenza</RadzenText>
|
||||
<RadzenDatePicker @bind-Value=@iscrizione.GiornoPresenza Name="GiornoPresenza" ShowCalendarWeek ShowTime="false"
|
||||
DateFormat="dd/MM/yyyy" Min="inizioEvento" Max="fineEvento" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Agente</RadzenText>
|
||||
<RadzenDropDown Style="width: 100%" TValue="Guid ?" @bind-Value=@iscrizione.AgenteId Data=@agenti TextProperty="Info" ValueProperty="Id" Name="agenteDrop" Disabled="@(agenti.Count() == 0)" />
|
||||
</div>
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Capoarea</RadzenText>
|
||||
<RadzenDropDown Style="width: 100%" TValue="Guid ?" @bind-Value=@iscrizione.CapoareaId Data=@capiarea TextProperty="Info" ValueProperty="Id" Name="capoareaDrop" Disabled="!isAdmin" Change="(x => OnCapoareaChange(x))" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-3 mb-3">
|
||||
<button type="button" class="btn btn-default w-100" @onclick="backToHome">
|
||||
Annulla
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-3 mb-3">
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
Salva
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Guid? IscrizioneId { get; set; }
|
||||
public Guid idClaim { get; set; }
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private IscrizioneEventoViewModel iscrizione { get; set; } = new();
|
||||
|
||||
private IEnumerable<DestinazioneViewModel> destinazioniList { get; set; }
|
||||
private IEnumerable<LookupViewModel<Guid>> tipologiaList { get; set; }
|
||||
private IEnumerable<string> esperienzaList { get; set; }
|
||||
private IEnumerable<LookupViewModel<int>> ruoloList { get; set; }
|
||||
private List<ProvinciaViewModel> provList { get; set; }
|
||||
private List<ComuneIstatViewModel> comuniList { get; set; }
|
||||
private IEnumerable<UtenteViewModel> agenti { get; set; } = new List<UtenteViewModel>();
|
||||
private IEnumerable<UtenteViewModel> capiarea { get; set; } = new List<UtenteViewModel>();
|
||||
|
||||
private DateTime inizioEvento { get; set; }
|
||||
private DateTime fineEvento { get; set; }
|
||||
|
||||
private bool isAdmin { get; set; } = false;
|
||||
private Guid capoareaId { get; set; } = Guid.Empty;
|
||||
|
||||
private string pageTitle => iscrizione?.Id == Guid.Empty ? "Nuova iscrizione" : "Modifica iscrizione";
|
||||
|
||||
private DialogOptions editNewDialogOption { get; set; } = new()
|
||||
{
|
||||
Resizable = false,
|
||||
Draggable = false,
|
||||
Width = "900px"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Creo tutte le drop necessarie per il form
|
||||
/// Controllo se l'utente è admin per permettergli la modifica dei capiarea
|
||||
/// Controllo se l'utente è capoarea o admin per permettergli la modifica degli agenti
|
||||
/// </summary>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var eUtils = new EnumUtils();
|
||||
idClaim = await MembershipUtils.GetUserId(auth);
|
||||
var idRuolo = await MembershipUtils.GetRoleId(auth);
|
||||
var ruolo = await _managerService.RuoloService.RicercaPer(
|
||||
x => x.Id == idRuolo && x.Permessi.Any(y => y.Feature.Type == FeatureType.Capoarea || y.Feature.Type == FeatureType.AdminGlobal),
|
||||
includi: x => x.Include(y => y.Permessi).ThenInclude(z => z.Feature));
|
||||
|
||||
isAdmin = ruolo?.Permessi.Where(x => x.Eliminato == false)?.Any(x => x.Feature.Type == FeatureType.AdminGlobal) ?? false;
|
||||
var a = ruolo?.Permessi.Where(x => x.Eliminato == false);
|
||||
|
||||
if (IscrizioneId.GetValueOrDefault() != Guid.Empty)
|
||||
iscrizione = await _managerService.IscrizioneEventoService.RicercaPer(x => x.Id == IscrizioneId, includi: x => x.Include(x => x.Comune).Include(x => x.Provincia).Include(y => y.Cliente).Include(y => y.Evento).Include(y => y.InvitoEvento));
|
||||
else
|
||||
iscrizione = new IscrizioneEventoViewModel();
|
||||
|
||||
destinazioniList = (await _managerService.DestinazioneService.RicercaQueryable(filtro: x => x.ClienteId == iscrizione.ClienteId.GetValueOrDefault())).Select(x => (DestinazioneViewModel)x).ToList();
|
||||
esperienzaList = new List<string>() { "Si", "No" };
|
||||
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();
|
||||
ruoloList = eUtils.GetEnumList<RuoloTipo>();
|
||||
provList = (await _managerService.ProvinciaIstatService.RicercaQueryable(x => x.Eliminato == false,ordinamento: x => x.OrderBy(y => y.Provincia))).Select(x => (ProvinciaViewModel)x).ToList();
|
||||
comuniList = (await _managerService.ComuneIstatService.RicercaQueryable(x => x.ProvinciaIstatId == iscrizione.ProvinciaId.GetValueOrDefault())).Select(x => (ComuneIstatViewModel)x).ToList();
|
||||
|
||||
capoareaId = iscrizione.CapoareaId.GetValueOrDefault();
|
||||
capiarea = (await _managerService.UtenteService.RicercaQueryable(
|
||||
x => x.Eliminato == false && x.IsCapoarea, ordinamento: x => x.OrderBy(y => y.Cognome).ThenBy(z => z.Nome))).Select(x => (UtenteViewModel)x).ToList();
|
||||
|
||||
if(capoareaId != Guid.Empty)
|
||||
agenti = (await _managerService.UtenteService.RicercaQueryable(
|
||||
x => x.Eliminato == false && (isAdmin || x.CapoareaId == idClaim) && !x.IsCapoarea && x.CapoareaId == iscrizione.CapoareaId,
|
||||
includi: x => x.Include(y => y.Capoarea), ordinamento: x => x.OrderBy(y => y.Cognome).ThenBy(z => z.Nome))).Select(x => (UtenteViewModel)x).ToList();
|
||||
|
||||
inizioEvento = iscrizione.Evento?.DataDa ?? DateTime.Now.AddDays(-7);
|
||||
fineEvento = iscrizione.Evento?.DataA ?? DateTime.Now.AddDays(7);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva il cliente: recupera o crea il modello, applica i dati dalla UI,
|
||||
/// collega l’agente, crea una destinazione di default se è un nuovo cliente
|
||||
/// e poi salva usando l’ID dell’utente loggato, tornando alla lista clienti.
|
||||
/// </summary>
|
||||
private async Task onIscrizioneSave()
|
||||
{
|
||||
var model = await _managerService.IscrizioneEventoService.RicercaPer(x => x.Id == iscrizione.Id, solaLettura: false) ?? new IscrizioneEvento();
|
||||
|
||||
model = iscrizione.Map(model);
|
||||
|
||||
await _managerService.IscrizioneEventoService.Salva(model, idClaim);
|
||||
_navManager.NavigateTo("/management/Iscrizioni");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Torna alla pagina di elenco clienti senza salvare altre modifiche.
|
||||
/// </summary>
|
||||
private void backToHome()
|
||||
{
|
||||
_navManager.NavigateTo("/management/Iscrizioni");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna la drop di agenti in base al valore di capoarea
|
||||
/// </summary>
|
||||
private async Task OnCapoareaChange(object value)
|
||||
{
|
||||
var capoId = Guid.Empty;
|
||||
|
||||
if (Guid.TryParse(value.ToString(), out capoId))
|
||||
{
|
||||
capoareaId = capoId;
|
||||
iscrizione.AgenteId = null;
|
||||
|
||||
agenti = iscrizione.CapoareaId == idClaim || isAdmin
|
||||
? (await _managerService.UtenteService.RicercaQueryable(
|
||||
x => x.Eliminato == false && (isAdmin || x.CapoareaId == idClaim) && !x.IsCapoarea && x.CapoareaId == capoareaId,
|
||||
includi: x => x.Include(y => y.Capoarea),
|
||||
ordinamento: x => x.OrderBy(y => y.Cognome).ThenBy(z => z.Nome)))
|
||||
.Select(x => (UtenteViewModel)x).ToList()
|
||||
: [await _managerService.UtenteService.RicercaPer(x => x.Id == iscrizione.AgenteId)];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna la drop dei comuni in base alla provincia
|
||||
/// </summary>
|
||||
private async Task onProvinciaChanged(object args)
|
||||
{
|
||||
Guid parsed;
|
||||
Guid.TryParse(args.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.ProvinciaId = prov.Id;
|
||||
iscrizione.ComuneId = null;
|
||||
|
||||
comuniList = (await _managerService.ComuneIstatService.RicercaQueryable(x => x.Provincia == prov.Sigla))
|
||||
.Select(x => (ComuneIstatViewModel)x).ToList();
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Ruolo</RadzenText>
|
||||
<RadzenDropDown Style="width: 100%" TValue="Guid" @bind-Value=@utente.RuoloId Data=@ruoli TextProperty="Nome" ValueProperty="Id" Name="ruoliDrop" />
|
||||
<RadzenDropDown Style="width: 100%" TValue="Guid?" @bind-Value=@utente.RuoloId Data=@ruoli TextProperty="Nome" ValueProperty="Id" Name="ruoliDrop" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -67,13 +67,21 @@
|
||||
</div>
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Capoarea</RadzenText>
|
||||
<RadzenDropDown Style="width: 100%" TValue="Guid" @bind-Value=@utente.CapoareaId Data=@capoareaList TextProperty="Nome" ValueProperty="Id" Name="capoareaDrop\" />
|
||||
<RadzenDropDown Style="width: 100%" TValue="Guid?" @bind-Value=@utente.CapoareaId Data=@capoareaList TextProperty="Nome" ValueProperty="Id" Name="capoareaDrop\" />
|
||||
</div>
|
||||
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Password</RadzenText>
|
||||
<RadzenPassword Style="width: 100%" aria-label="Password" @bind-Value="@utente.Password"/>
|
||||
<RadzenPassword Style="width: 100%" aria-label="Password" @bind-Value="@utente.Password" />
|
||||
</div>
|
||||
|
||||
@if (utente.IsCapoarea)
|
||||
{
|
||||
<div class="col-3 mb-3">
|
||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Provincia Associata</RadzenText>
|
||||
<RadzenDropDown Style="width: 100%" TValue="Guid?" @bind-Value=@utente.ProvinciaId Data=@province TextProperty="Description" ValueProperty="Key" Name="provinceDrop" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@ -107,6 +115,7 @@
|
||||
private UtenteViewModel? utente { get; set; } = new();
|
||||
private List<UtenteViewModel> capoareaList { get; set; } = new();
|
||||
private List<RuoloViewModel> ruoli { get; set; } = new();
|
||||
private List<LookupViewModel<Guid?>> province { get; set; } = new();
|
||||
|
||||
private string pageTitle => utente?.Id == Guid.Empty ? "Nuovo utente" : "Modifica utente";
|
||||
|
||||
@ -119,16 +128,18 @@
|
||||
if (UserId.GetValueOrDefault() != Guid.Empty)
|
||||
utente = await _managerService.UtenteService.RicercaPer(
|
||||
x => x.Id == UserId,
|
||||
includi:x => x.Include(y => y.Ruolo).Include(y => y.Capoarea));
|
||||
includi: x => x.Include(y => y.Ruolo).Include(y => y.Capoarea));
|
||||
else
|
||||
utente = new UtenteViewModel();
|
||||
|
||||
ruoli = (await _managerService.RuoloService.RicercaQueryable(x => x.Eliminato == false))
|
||||
.Select(x => (RuoloViewModel)x).ToList();
|
||||
|
||||
province = (await _managerService.ProvinciaIstatService.RicercaQueryable(x => x.Eliminato == false && (!x.UtentiList.Any() || x.UtentiList.Any(x => x.Id == utente.Id)))).Select(x => new LookupViewModel<Guid?>(x.Id, x.Provincia)).ToList();
|
||||
|
||||
var ruoliCapoarea = await _managerService.RuoloService.RicercaQueryable(
|
||||
x => x.Permessi.Any(y => y.Feature.Type == FeatureType.AdminGlobal || y.Feature.Type == FeatureType.Capoarea),
|
||||
includi:x => x.Include(y => y.Permessi).ThenInclude(z => z.Feature));
|
||||
includi: x => x.Include(y => y.Permessi).ThenInclude(z => z.Feature));
|
||||
capoareaList = (await _managerService.UtenteService.RicercaQueryable(
|
||||
u => ruoliCapoarea.Any(r => r.Id == u.RuoloId)
|
||||
)).Select(x => (UtenteViewModel)x).ToList();
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
<div class="container my-5 py-3">
|
||||
<ClienteToggle ValueChanged="onClienteToggleChanged" />
|
||||
@if (showCodiceCliente)
|
||||
@* @if (showCodiceCliente)
|
||||
{
|
||||
<div class="col-12">
|
||||
<div class="row">
|
||||
@ -24,7 +24,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
} *@
|
||||
|
||||
@if (showForm)
|
||||
{
|
||||
|
||||
@ -29,9 +29,11 @@ public class IscrizioneEventoViewModel
|
||||
[Required(ErrorMessage = "Il numero di telefono è obbigatorio")]
|
||||
public string NumeroTelefono { get; set; }
|
||||
[Required(ErrorMessage = "La provincia è obbigatoria")]
|
||||
public Guid? Provincia { get; set; }
|
||||
public Guid? ProvinciaId { get; set; }
|
||||
public ProvinciaViewModel Provincia { get; set; }
|
||||
[Required(ErrorMessage = "Il comune è obbigatorio")]
|
||||
public Guid? Comune { get; set; }
|
||||
public Guid? ComuneId { get; set; }
|
||||
public ComuneIstatViewModel Comune { get; set; }
|
||||
[Required(ErrorMessage = "Il CAP è obbigatorio")]
|
||||
public string Cap { get; set; }
|
||||
[Required(ErrorMessage = "La Ragione Sociale è obbigatoria")]
|
||||
@ -46,13 +48,12 @@ public class IscrizioneEventoViewModel
|
||||
public string? PartitaIva { get; set; }
|
||||
[Required(ErrorMessage = "E' necessario indicare la data di partecipazione")]
|
||||
public DateTime? GiornoPresenza { get; set; }
|
||||
public Guid? AgenteId { get; set; }
|
||||
public Guid? CapoareaId { get; set; }
|
||||
|
||||
public IscrizioneEvento Map(IscrizioneEvento model)
|
||||
{
|
||||
model.Partecipanti = Partecipanti;
|
||||
model.Note = Note;
|
||||
model.ScanCompleto = ScanCompleto;
|
||||
model.DataScan = DataScan;
|
||||
model.Nome = Nome;
|
||||
model.Cognome = Cognome;
|
||||
model.Email = Email;
|
||||
@ -62,8 +63,12 @@ public class IscrizioneEventoViewModel
|
||||
model.EsperienzaConDAC = EsperienzaConDAC;
|
||||
model.PartitaIva = PartitaIva;
|
||||
model.GiornoPresenza = GiornoPresenza.Value;
|
||||
model.ComuneId = Comune.GetValueOrDefault();
|
||||
model.ProvinciaId = Provincia.GetValueOrDefault();
|
||||
model.Ruolo = (RuoloTipo)RuoloInt;
|
||||
model.TipologiaClienteId = TipologiaClienteId;
|
||||
model.ComuneId = ComuneId.GetValueOrDefault();
|
||||
model.ProvinciaId = ProvinciaId.GetValueOrDefault();
|
||||
model.AgenteId = AgenteId;
|
||||
model.CapoareaId = CapoareaId;
|
||||
|
||||
return model;
|
||||
}
|
||||
@ -86,8 +91,10 @@ public class IscrizioneEventoViewModel
|
||||
Cognome = model.Cognome,
|
||||
Email = model.Email,
|
||||
NumeroTelefono = model.NumeroTelefono,
|
||||
Provincia = model.Provincia?.Id ?? Guid.Empty,
|
||||
Comune = model.Comune?.Id ?? Guid.Empty,
|
||||
ProvinciaId = model.Provincia?.Id ?? Guid.Empty,
|
||||
Provincia = model.Provincia,
|
||||
ComuneId = model.Comune?.Id ?? Guid.Empty,
|
||||
Comune = model.Comune,
|
||||
Cap = model.Cap,
|
||||
RagioneSociale = model.RagioneSociale,
|
||||
EsperienzaConDAC = model.EsperienzaConDAC,
|
||||
@ -96,6 +103,8 @@ public class IscrizioneEventoViewModel
|
||||
RuoloInt = (int?)model.Ruolo,
|
||||
PartitaIva = model.PartitaIva,
|
||||
GiornoPresenza = model.GiornoPresenza,
|
||||
CapoareaId = model.CapoareaId,
|
||||
AgenteId = model.AgenteId,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ public class ProvinciaViewModel
|
||||
public Guid Id { get; set; }
|
||||
public string Sigla { get; set; }
|
||||
public string Provincia { get; set; }
|
||||
public bool CapoareaDaVerificare { get; set; }
|
||||
public string Info => $"{Sigla} - {Provincia}";
|
||||
|
||||
public static implicit operator ProvinciaViewModel(ProvinciaIstat model)
|
||||
@ -17,6 +18,7 @@ public class ProvinciaViewModel
|
||||
{
|
||||
Provincia = model.Provincia,
|
||||
Sigla = model.Sigla,
|
||||
CapoareaDaVerificare = model.CapoareaDaVerificare,
|
||||
Id = model.Id
|
||||
};
|
||||
}
|
||||
|
||||
@ -16,9 +16,10 @@ public class UtenteViewModel
|
||||
public string Nome { get; set; }
|
||||
[Required(ErrorMessage = "Il cognome è obbligatorio")]
|
||||
public string Cognome { get; set; }
|
||||
public Guid RuoloId { get; set; }
|
||||
public Guid CapoareaId { get; set; }
|
||||
public Guid? RuoloId { get; set; }
|
||||
public Guid? CapoareaId { get; set; }
|
||||
public bool IsCapoarea { get; set; }
|
||||
public Guid? ProvinciaId { get; set; }
|
||||
public string Info => $"{Nome} {Cognome}";
|
||||
|
||||
public static implicit operator UtenteViewModel(Utente? model)
|
||||
@ -30,9 +31,10 @@ public class UtenteViewModel
|
||||
Email = model.Email,
|
||||
Nome = model.Nome,
|
||||
Cognome = model.Cognome,
|
||||
RuoloId = model.Ruolo?.Id ?? Guid.Empty,
|
||||
CapoareaId = model.Capoarea?.Id ?? Guid.Empty,
|
||||
IsCapoarea = model.IsCapoarea
|
||||
RuoloId = model.Ruolo?.Id,
|
||||
CapoareaId = model.Capoarea?.Id,
|
||||
IsCapoarea = model.IsCapoarea,
|
||||
ProvinciaId = model.ProvinciaIstatId
|
||||
};
|
||||
}
|
||||
|
||||
@ -42,6 +44,7 @@ public class UtenteViewModel
|
||||
model.Cognome = Cognome;
|
||||
model.Email = Email;
|
||||
model.IsCapoarea = IsCapoarea;
|
||||
model.ProvinciaIstatId = ProvinciaId;
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user