("TipologiaGestionale")
+ .HasColumnType("nvarchar(max)");
+
b.HasKey("Id");
b.HasIndex("AgenteId");
diff --git a/StandManager/Components/Pages/Management/Clienti_Edit.razor b/StandManager/Components/Pages/Management/Clienti_Edit.razor
index 788f474..453a3d1 100644
--- a/StandManager/Components/Pages/Management/Clienti_Edit.razor
+++ b/StandManager/Components/Pages/Management/Clienti_Edit.razor
@@ -98,6 +98,10 @@
Stato
+
+ Tipologia Gestionale
+
+
diff --git a/StandManager/Components/Pages/Management/Clienti_Import.razor b/StandManager/Components/Pages/Management/Clienti_Import.razor
index a3899ca..c511277 100644
--- a/StandManager/Components/Pages/Management/Clienti_Import.razor
+++ b/StandManager/Components/Pages/Management/Clienti_Import.razor
@@ -68,18 +68,32 @@
model.Rid = firstRow.CodCli;
model.RagioneSociale = firstRow.RagSocCliente;
model.PartitaIva = firstRow.PartitaIva;
+
+ var capoArea = await _managerService.UtenteService.RicercaPer(filtro: x => x.CodiceAgente == firstRow.CapoArea, solaLettura: false) ?? new Utente();
+ capoArea = await mapCapoArea(capoArea, firstRow);
+ if (capoArea.Id == Guid.Empty) capoArea.Password = "";
+ var savedCapoArea = await _managerService.UtenteService.Salva(capoArea, idClaim);
+ model.CapoareaId = savedCapoArea.Id;
+
+ var agente = await _managerService.UtenteService.RicercaPer(filtro: x => x.CodiceAgente == firstRow.Agente, solaLettura: false) ?? new Utente();
+ agente = await mapAgente(agente, firstRow, model.CapoareaId);
+ if (agente.Id == Guid.Empty) agente.Password = "";
+ var savedAgente = await _managerService.UtenteService.Salva(agente, idClaim);
+ model.AgenteId = savedAgente.Id;
+
model.Destinazioni ??= new();
foreach (var destinazioneRiga in rows)
{
var destinazione = model.Destinazioni.FirstOrDefault(x => x.Rid == destinazioneRiga.CodCli) ?? new Destinazione();
- destinazione = mapDestinazione(destinazione, model.Id, destinazioneRiga);
+ destinazione = await mapDestinazione(destinazione, model.Id, destinazioneRiga, model.AgenteId);
if (destinazione.Id == Guid.Empty)
model.Destinazioni.Add(destinazione);
}
+
return model;
}
- private Destinazione mapDestinazione(Destinazione model, Guid clienteId, ClienteExcelViewModel row)
+ private async Task mapDestinazione(Destinazione model, Guid clienteId, ClienteExcelViewModel row, Guid? agenteId)
{
model.Rid = row.CodDes;
model.RagioneSociale = row.RagSocDestinazione;
@@ -91,6 +105,31 @@
model.Email = row.MailFatturazione;
model.EmailInvito = row.MailFatturazione;
model.NumeroTelefono = row.Telefono;
+ model.AgenteId = agenteId;
+
+ return model;
+ }
+
+ private async Task mapCapoArea(Utente model, ClienteExcelViewModel row)
+ {
+ model.Username = row.DescrizioneCapoArea;
+ model.CodiceAgente = row.CapoArea;
+ model.Nome = row.DescrizioneCapoArea;
+ model.Cognome = "";
+ model.Email = "";
+
+ return model;
+ }
+
+ private async Task mapAgente(Utente model, ClienteExcelViewModel row, Guid? capoareaId)
+ {
+ model.Username = row.DescrizioneAgente;
+ model.CodiceAgente = row.Agente;
+ model.Nome = row.DescrizioneAgente;
+ model.Cognome = "";
+ model.Email = "";
+ model.CapoareaId = capoareaId;
+
return model;
}
}
diff --git a/StandManager/Model/ClienteViewModel.cs b/StandManager/Model/ClienteViewModel.cs
index 0e3e7a7..4c6891d 100644
--- a/StandManager/Model/ClienteViewModel.cs
+++ b/StandManager/Model/ClienteViewModel.cs
@@ -26,6 +26,7 @@ public class ClienteViewModel
public Guid? TipologiaClienteId { get; set; }
public ClienteStato StatoCliente { get; set; }
public int StatoClienteInt { get; set; }
+ public string TipologiaGestionale { get; set; }
public static implicit operator ClienteViewModel(Cliente model)
{
@@ -33,7 +34,7 @@ public class ClienteViewModel
? null
: new ClienteViewModel()
{
- NomeAgente = model.Agente?.ToString(),
+ NomeAgente = model.Agente?.Nome.ToString(),
Agente = model.Agente,
AgenteId = model.AgenteId,
Cap = model.Cap,
@@ -50,7 +51,8 @@ public class ClienteViewModel
TipologiaCliente = model.TipologiaCliente,
TipologiaClienteId = model.TipologiaCliente?.Id ?? Guid.Empty,
StatoCliente = model.StatoCliente,
- StatoClienteInt = (int)model.StatoCliente
+ StatoClienteInt = (int)model.StatoCliente,
+ TipologiaGestionale = model.TipologiaGestionale
};
}
@@ -66,6 +68,7 @@ public class ClienteViewModel
model.NumeroTelefono = NumeroTelefono;
model.Rid = Rid;
model.StatoCliente = (ClienteStato)StatoClienteInt;
+ model.TipologiaGestionale = TipologiaGestionale;
return model;
}