- Agenti e CapoArea in Clienti_Import + TipologiaGestionale in Clienti
This commit is contained in:
@ -31,6 +31,7 @@ public class Cliente : EntitaBase
|
|||||||
public Guid? TipologiaClienteId { get; set; }
|
public Guid? TipologiaClienteId { get; set; }
|
||||||
public TipologiaCliente TipologiaCliente { get; set; }
|
public TipologiaCliente TipologiaCliente { get; set; }
|
||||||
public ClienteStato StatoCliente { get; set; }
|
public ClienteStato StatoCliente { get; set; }
|
||||||
|
public string? TipologiaGestionale { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ClienteStato
|
public enum ClienteStato
|
||||||
|
|||||||
1025
StandManager.Infrastructure/Migrations/20251218104848_ClienteTipologiaGestionale.Designer.cs
generated
Normal file
1025
StandManager.Infrastructure/Migrations/20251218104848_ClienteTipologiaGestionale.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace StandManager.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ClienteTipologiaGestionale : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "TipologiaGestionale",
|
||||||
|
table: "Cliente",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TipologiaGestionale",
|
||||||
|
table: "Cliente");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -84,6 +84,9 @@ namespace StandManager.Infrastructure.Migrations
|
|||||||
b.Property<Guid?>("TipologiaClienteId")
|
b.Property<Guid?>("TipologiaClienteId")
|
||||||
.HasColumnType("uniqueidentifier");
|
.HasColumnType("uniqueidentifier");
|
||||||
|
|
||||||
|
b.Property<string>("TipologiaGestionale")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("AgenteId");
|
b.HasIndex("AgenteId");
|
||||||
|
|||||||
@ -98,6 +98,10 @@
|
|||||||
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Stato</RadzenText>
|
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Stato</RadzenText>
|
||||||
<RadzenDropDown Style="width: 100%" TValue="int" @bind-Value=@cliente.StatoClienteInt Data=@statoCliente TextProperty="Description" ValueProperty="Key" Name="statoClienteDrop" />
|
<RadzenDropDown Style="width: 100%" TValue="int" @bind-Value=@cliente.StatoClienteInt Data=@statoCliente TextProperty="Description" ValueProperty="Key" Name="statoClienteDrop" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-3 mb-3">
|
||||||
|
<RadzenText TextStyle="TextStyle.Subtitle2" TagName="TagName.H3">Tipologia Gestionale</RadzenText>
|
||||||
|
<RadzenTextBox Style="width: 100%" aria-label="Email" @bind-Value="@cliente.TipologiaGestionale" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@ -68,18 +68,32 @@
|
|||||||
model.Rid = firstRow.CodCli;
|
model.Rid = firstRow.CodCli;
|
||||||
model.RagioneSociale = firstRow.RagSocCliente;
|
model.RagioneSociale = firstRow.RagSocCliente;
|
||||||
model.PartitaIva = firstRow.PartitaIva;
|
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();
|
model.Destinazioni ??= new();
|
||||||
foreach (var destinazioneRiga in rows)
|
foreach (var destinazioneRiga in rows)
|
||||||
{
|
{
|
||||||
var destinazione = model.Destinazioni.FirstOrDefault(x => x.Rid == destinazioneRiga.CodCli) ?? new Destinazione();
|
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)
|
if (destinazione.Id == Guid.Empty)
|
||||||
model.Destinazioni.Add(destinazione);
|
model.Destinazioni.Add(destinazione);
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Destinazione mapDestinazione(Destinazione model, Guid clienteId, ClienteExcelViewModel row)
|
private async Task<Destinazione> mapDestinazione(Destinazione model, Guid clienteId, ClienteExcelViewModel row, Guid? agenteId)
|
||||||
{
|
{
|
||||||
model.Rid = row.CodDes;
|
model.Rid = row.CodDes;
|
||||||
model.RagioneSociale = row.RagSocDestinazione;
|
model.RagioneSociale = row.RagSocDestinazione;
|
||||||
@ -91,6 +105,31 @@
|
|||||||
model.Email = row.MailFatturazione;
|
model.Email = row.MailFatturazione;
|
||||||
model.EmailInvito = row.MailFatturazione;
|
model.EmailInvito = row.MailFatturazione;
|
||||||
model.NumeroTelefono = row.Telefono;
|
model.NumeroTelefono = row.Telefono;
|
||||||
|
model.AgenteId = agenteId;
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<Utente> 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<Utente> 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;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ public class ClienteViewModel
|
|||||||
public Guid? TipologiaClienteId { get; set; }
|
public Guid? TipologiaClienteId { get; set; }
|
||||||
public ClienteStato StatoCliente { get; set; }
|
public ClienteStato StatoCliente { get; set; }
|
||||||
public int StatoClienteInt { get; set; }
|
public int StatoClienteInt { get; set; }
|
||||||
|
public string TipologiaGestionale { get; set; }
|
||||||
|
|
||||||
public static implicit operator ClienteViewModel(Cliente model)
|
public static implicit operator ClienteViewModel(Cliente model)
|
||||||
{
|
{
|
||||||
@ -33,7 +34,7 @@ public class ClienteViewModel
|
|||||||
? null
|
? null
|
||||||
: new ClienteViewModel()
|
: new ClienteViewModel()
|
||||||
{
|
{
|
||||||
NomeAgente = model.Agente?.ToString(),
|
NomeAgente = model.Agente?.Nome.ToString(),
|
||||||
Agente = model.Agente,
|
Agente = model.Agente,
|
||||||
AgenteId = model.AgenteId,
|
AgenteId = model.AgenteId,
|
||||||
Cap = model.Cap,
|
Cap = model.Cap,
|
||||||
@ -50,7 +51,8 @@ public class ClienteViewModel
|
|||||||
TipologiaCliente = model.TipologiaCliente,
|
TipologiaCliente = model.TipologiaCliente,
|
||||||
TipologiaClienteId = model.TipologiaCliente?.Id ?? Guid.Empty,
|
TipologiaClienteId = model.TipologiaCliente?.Id ?? Guid.Empty,
|
||||||
StatoCliente = model.StatoCliente,
|
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.NumeroTelefono = NumeroTelefono;
|
||||||
model.Rid = Rid;
|
model.Rid = Rid;
|
||||||
model.StatoCliente = (ClienteStato)StatoClienteInt;
|
model.StatoCliente = (ClienteStato)StatoClienteInt;
|
||||||
|
model.TipologiaGestionale = TipologiaGestionale;
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user