From 18e39cc6a1fce98cd9b99114dd5b33f55cf7a6f3 Mon Sep 17 00:00:00 2001 From: Gianmarco Date: Wed, 17 Dec 2025 08:55:21 +0100 Subject: [PATCH] Permessi_Parziale --- .idea/.idea.StandManager/.idea/.name | 1 + StandManager.Domain/Entita/Feature.cs | 21 ++++++ StandManager.Domain/Entita/Permission.cs | 14 ++++ StandManager.Domain/Entita/Referente.cs | 4 +- StandManager.Domain/Entita/Ruolo.cs | 19 ++++++ StandManager.Domain/Entita/Sezione.cs | 12 ++++ StandManager.Domain/Entita/Utente.cs | 5 ++ .../DAL/Context/StandManagerDbContext.cs | 5 +- .../Pages/Component_Registrazione.razor | 26 ++++---- StandManager/Components/Pages/Home.razor | 12 +++- .../Pages/Management/Clienti_Import.razor | 39 ++++++----- StandManager/Model/ClienteExcelViewModel.cs | 64 +++++++++++++++++++ StandManager/Model/DestinazioneViewModel.cs | 2 + StandManager/Model/InvitoEventoViewModel.cs | 3 +- StandManager/Model/ReferenteViewModel.cs | 2 +- 15 files changed, 191 insertions(+), 38 deletions(-) create mode 100644 .idea/.idea.StandManager/.idea/.name create mode 100644 StandManager.Domain/Entita/Feature.cs create mode 100644 StandManager.Domain/Entita/Permission.cs create mode 100644 StandManager.Domain/Entita/Ruolo.cs create mode 100644 StandManager.Domain/Entita/Sezione.cs create mode 100644 StandManager/Model/ClienteExcelViewModel.cs diff --git a/.idea/.idea.StandManager/.idea/.name b/.idea/.idea.StandManager/.idea/.name new file mode 100644 index 0000000..da2cd30 --- /dev/null +++ b/.idea/.idea.StandManager/.idea/.name @@ -0,0 +1 @@ +StandManager \ No newline at end of file diff --git a/StandManager.Domain/Entita/Feature.cs b/StandManager.Domain/Entita/Feature.cs new file mode 100644 index 0000000..85aad86 --- /dev/null +++ b/StandManager.Domain/Entita/Feature.cs @@ -0,0 +1,21 @@ +using StandManager.Domain.Entita.Base; + +namespace StandManager.Domain.Entita; + +public class Feature : EntitaBase +{ + public string Nome { get; set; } + public string Descrizione { get; set; } + public int Ordinamento { get; set; } + public Sezione Sezione { get; set; } + public FeatureType Type { get; set; } +} + +public enum FeatureType +{ + Any = -99, + Insert = 0, + Edit, + Delete, + AdminGlobal = 100 +} diff --git a/StandManager.Domain/Entita/Permission.cs b/StandManager.Domain/Entita/Permission.cs new file mode 100644 index 0000000..6544407 --- /dev/null +++ b/StandManager.Domain/Entita/Permission.cs @@ -0,0 +1,14 @@ +using StandManager.Domain.Entita.Base; +using System.ComponentModel.DataAnnotations.Schema; + +namespace StandManager.Domain.Entita; + +public class Permission : EntitaBase +{ + [ForeignKey(nameof(Ruolo))] + public Guid? RuoloId { get; set; } + public Ruolo Ruolo { get; set; } + [ForeignKey(nameof(Feature))] + public Guid IdFeature { get; set; } + public Feature Feature { get; set; } +} \ No newline at end of file diff --git a/StandManager.Domain/Entita/Referente.cs b/StandManager.Domain/Entita/Referente.cs index be35519..158f0ee 100644 --- a/StandManager.Domain/Entita/Referente.cs +++ b/StandManager.Domain/Entita/Referente.cs @@ -12,11 +12,11 @@ public class Referente : EntitaBase public string Cognome { get; set; } public string Email { get; set; } public string NumeroTelefono { get; set; } - public Ruolo Ruolo { get; set; } + public RuoloReferente Ruolo { get; set; } public string RuoloNote { get; set; } } -public enum Ruolo +public enum RuoloReferente { Ruolo1 = 0, Ruolo2, diff --git a/StandManager.Domain/Entita/Ruolo.cs b/StandManager.Domain/Entita/Ruolo.cs new file mode 100644 index 0000000..40e7981 --- /dev/null +++ b/StandManager.Domain/Entita/Ruolo.cs @@ -0,0 +1,19 @@ +using StandManager.Domain.Entita.Base; +using System.ComponentModel.DataAnnotations.Schema; + +namespace StandManager.Domain.Entita; + +public class Ruolo : EntitaBase +{ + public Ruolo() + { + Nome = string.Empty; + } + public string Nome { get; set; } + + [InverseProperty(nameof(Utente.Ruolo))] + public List Utenti { get; set; } + + [InverseProperty(nameof(Permission.Ruolo))] + public virtual List Permessi { get; set; } +} diff --git a/StandManager.Domain/Entita/Sezione.cs b/StandManager.Domain/Entita/Sezione.cs new file mode 100644 index 0000000..ea3be87 --- /dev/null +++ b/StandManager.Domain/Entita/Sezione.cs @@ -0,0 +1,12 @@ +using StandManager.Domain.Entita.Base; +using System.ComponentModel.DataAnnotations.Schema; + +namespace StandManager.Domain.Entita; + +public class Sezione : EntitaBase +{ + public string Nome { get; set; } + public int Ordinamento { get; set; } + [InverseProperty(nameof(Feature.Sezione))] + public List Features { get; set; } +} \ No newline at end of file diff --git a/StandManager.Domain/Entita/Utente.cs b/StandManager.Domain/Entita/Utente.cs index 78dae3a..a2fa6b1 100644 --- a/StandManager.Domain/Entita/Utente.cs +++ b/StandManager.Domain/Entita/Utente.cs @@ -1,4 +1,5 @@ using StandManager.Domain.Entita.Base; +using System.ComponentModel.DataAnnotations.Schema; namespace StandManager.Domain.Entita; @@ -16,6 +17,10 @@ public class Utente : EntitaBase public string Nome { get; set; } public string Cognome { get; set; } public string? CodiceAgente { get; set; } + [ForeignKey(nameof(Ruolo))] + public Guid? RuoloId { get; set; } + public Ruolo Ruolo { get; set; } + public override string ToString() { return $"{Nome} {Cognome}"; diff --git a/StandManager.Infrastructure/DAL/Context/StandManagerDbContext.cs b/StandManager.Infrastructure/DAL/Context/StandManagerDbContext.cs index 594ab88..506a8e0 100644 --- a/StandManager.Infrastructure/DAL/Context/StandManagerDbContext.cs +++ b/StandManager.Infrastructure/DAL/Context/StandManagerDbContext.cs @@ -16,11 +16,13 @@ public class StandManagerDbContext : OAServiceContext public DbSet Evento { get; set; } public DbSet InvitoEvento { get; set; } public DbSet IscrizioneEvento { get; set; } + public DbSet Permission { get; set; } public DbSet Referente { get; set; } + public DbSet Ruolo { get; set; } + public DbSet Sezione { get; set; } public DbSet TipologiaCliente { get; set; } public DbSet Utente { get; set; } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { base.OnConfiguring(optionsBuilder); @@ -29,6 +31,5 @@ public class StandManagerDbContext : OAServiceContext { optionsBuilder.UseSqlServer("Data Source=192.168.0.233\\SQL2019;Initial Catalog=DAC_StandManager;Persist Security Info=True;User ID=dac_user;Password=KZ4ZrUPzJV;TrustServerCertificate=True"); } - } } \ No newline at end of file diff --git a/StandManager/Components/Pages/Component_Registrazione.razor b/StandManager/Components/Pages/Component_Registrazione.razor index 35d200c..ffa25fc 100644 --- a/StandManager/Components/Pages/Component_Registrazione.razor +++ b/StandManager/Components/Pages/Component_Registrazione.razor @@ -94,7 +94,7 @@
-
@@ -107,21 +107,18 @@
-
- - - - -
-
- -
-
+
+
+ + + + +
@@ -140,7 +137,10 @@
-
+
+ +
+
@@ -208,6 +208,8 @@ iscrizione.ClienteId = invito.ClienteId; iscrizione.RagioneSociale = invito.RagioneSociale; + StateHasChanged(); + var destinazioniIds = invito.IscrizioniEvento?.Select(x => x.DestinazioneId).ToList() ?? new List(); destinazioniList = (await _managerService.DestinazioneService.RicercaQueryable(filtro: x => x.ClienteId == invito.ClienteId && !destinazioniIds.Any(y => y == x.Id))) .Select(x => (DestinazioneViewModel)x).ToList(); diff --git a/StandManager/Components/Pages/Home.razor b/StandManager/Components/Pages/Home.razor index cd01079..362d004 100644 --- a/StandManager/Components/Pages/Home.razor +++ b/StandManager/Components/Pages/Home.razor @@ -41,7 +41,7 @@ { @if (destinazioniList.Count() > 0) { - + } else { @@ -104,27 +104,33 @@ public Guid? invitationId { get; set; } public string invitationCode { get; set; } = string.Empty; - private InvitoEvento invito { get; set; } + private InvitoEventoViewModel invito { get; set; } private string invalidCode = string.Empty; private IEnumerable destinazioniList { get; set; } + private Component_Registrazione registrazione { get; set; } protected override async Task OnInitializedAsync() { base.OnInitializedAsync(); - invito = invitationId.GetValueOrDefault() != Guid.Empty + var dbInvito = invitationId.GetValueOrDefault() != Guid.Empty ? await _managerService.InvitoEventoService.RicercaPer(x => x.Id == invitationId && x.Eliminato == false, includi: x => x.Include(y => y.Evento).Include(y => y.Cliente).ThenInclude(y => y.Destinazioni).Include(y => y.IscrizioniEvento)) : new(); + invito = dbInvito; + var destinazioniIds = invito.IscrizioniEvento?.Select(x => x.DestinazioneId).ToList() ?? new List(); destinazioniList = (await _managerService.DestinazioneService.RicercaQueryable(filtro: x => x.ClienteId == invito.ClienteId && !destinazioniIds.Any(y => y == x.Id))).Select(x => (DestinazioneViewModel)x).ToList(); + StateHasChanged(); } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) await BodyClass.SetBodyClass("body-marketing body-gradient"); + if (invito.Id != Guid.Empty && registrazione != null) + await registrazione.SetDatiCliente(); } private void reloadWithCode() diff --git a/StandManager/Components/Pages/Management/Clienti_Import.razor b/StandManager/Components/Pages/Management/Clienti_Import.razor index 5a69efa..a3899ca 100644 --- a/StandManager/Components/Pages/Management/Clienti_Import.razor +++ b/StandManager/Components/Pages/Management/Clienti_Import.razor @@ -1,5 +1,6 @@ @using ClosedXML.Excel @using Microsoft.EntityFrameworkCore +@using StandManager.Model @attribute [Authorize] @rendermode InteractiveServer @@ -32,14 +33,18 @@ using var workbook = new XLWorkbook(ms); var ws = workbook.Worksheet(1); var usedRange = ws.RangeUsed(); + var rows = new List(usedRange.RowCount() - 1); - var ragioniSociali = ws.RangeUsed().RowsUsed().Skip(1).Select(r => new { Rid = r.Cell(1).GetString(), RagioneSociale = r.Cell(4).GetString() }).Distinct().ToList(); + foreach (var row in usedRange.RowsUsed().Skip(1)) + rows.Add(new ClienteExcelViewModel(row)); + + var ragioniSociali = rows.Select(r => new { Rid = r.CodCli, RagioneSociale = r.RagSocCliente }).Distinct().ToList(); clientiTotali = ragioniSociali.Count; counterLabel = " di " + clientiTotali; foreach (var cliente in ragioniSociali) { - var righeCliente = usedRange.RowsUsed().Where(r => r.Cell(1).GetString() == cliente.Rid).ToList(); + var righeCliente = rows.Where(r => r.CodCli == cliente.Rid).ToList(); var clienteDb = await _managerService.ClienteService.RicercaPer( x => x.Rid == cliente.Rid && x.Eliminato == false, @@ -56,17 +61,17 @@ _dialogService.Close(); } - private async Task mapCliente(Cliente model, List rows) + private async Task mapCliente(Cliente model, List rows) { var idClaim = await MembershipUtils.GetUserId(auth); var firstRow = rows.First(); - model.Rid = firstRow.Cell(1).GetString(); - model.RagioneSociale = firstRow.Cell(4).GetString(); - model.PartitaIva = firstRow.Cell(5).GetString(); + model.Rid = firstRow.CodCli; + model.RagioneSociale = firstRow.RagSocCliente; + model.PartitaIva = firstRow.PartitaIva; model.Destinazioni ??= new(); foreach (var destinazioneRiga in rows) { - var destinazione = model.Destinazioni.FirstOrDefault(x => x.Rid == destinazioneRiga.Cell(2).GetString()) ?? new Destinazione(); + var destinazione = model.Destinazioni.FirstOrDefault(x => x.Rid == destinazioneRiga.CodCli) ?? new Destinazione(); destinazione = mapDestinazione(destinazione, model.Id, destinazioneRiga); if (destinazione.Id == Guid.Empty) model.Destinazioni.Add(destinazione); @@ -74,18 +79,18 @@ return model; } - private Destinazione mapDestinazione(Destinazione model, Guid clienteId, IXLRangeRow? row) + private Destinazione mapDestinazione(Destinazione model, Guid clienteId, ClienteExcelViewModel row) { - model.Rid = row.Cell(2).GetString(); - model.RagioneSociale = row.Cell(7).GetString(); - model.PartitaIva = row.Cell(5).GetString(); + model.Rid = row.CodDes; + model.RagioneSociale = row.RagSocDestinazione; + model.PartitaIva = row.PartitaIva; model.ClienteId = clienteId; - model.Indirizzo = $"{row.Cell(8).GetString()} {row.Cell(9).GetString()}"; - model.Cap = row.Cell(15).GetString(); - model.Citta = row.Cell(11).GetString(); - model.Email = row.Cell(21).GetString(); - model.EmailInvito = row.Cell(21).GetString(); - model.NumeroTelefono = row.Cell(16).GetString(); + model.Indirizzo = $"{row.Indirizzo} {row.NumeroCivico}"; + model.Cap = row.Cap; + model.Citta = row.Comune; + model.Email = row.MailFatturazione; + model.EmailInvito = row.MailFatturazione; + model.NumeroTelefono = row.Telefono; return model; } } diff --git a/StandManager/Model/ClienteExcelViewModel.cs b/StandManager/Model/ClienteExcelViewModel.cs new file mode 100644 index 0000000..d02b9b9 --- /dev/null +++ b/StandManager/Model/ClienteExcelViewModel.cs @@ -0,0 +1,64 @@ +using ClosedXML.Excel; + +namespace StandManager.Model; + +public class ClienteExcelViewModel +{ + public ClienteExcelViewModel(IXLRangeRow row) + { + CodCli = row.Cell(1).GetString(); + CodDes = row.Cell(2).GetString(); + Tipologia = row.Cell(3).GetString(); + RagSocCliente = row.Cell(4).GetString(); + PartitaIva = row.Cell(5).GetString(); + CodiceFiscale = row.Cell(6).GetString(); + RagSocDestinazione = row.Cell(7).GetString(); + Indirizzo = row.Cell(8).GetString(); + NumeroCivico = row.Cell(9).GetString(); + Istat = row.Cell(10).GetString(); + Comune = row.Cell(11).GetString(); + Provincia = row.Cell(12).GetString(); + CodRegione = row.Cell(13).GetString(); + Regione = row.Cell(14).GetString(); + Cap = row.Cell(15).GetString(); + Telefono = row.Cell(16).GetString(); + Agente = row.Cell(17).GetString(); + DescrizioneAgente = row.Cell(18).GetString(); + CapoArea = row.Cell(19).GetString(); + DescrizioneCapoArea = row.Cell(20).GetString(); + MailFatturazione = row.Cell(21).GetString(); + DataCreazione = row.Cell(22).GetString(); + DataUltimoOrdine = row.Cell(23).GetString(); + DataUltimaFattura = row.Cell(24).GetString(); + CoordX = row.Cell(25).GetString(); + CoordY = row.Cell(26).GetString(); + } + + public string CodCli { get; set; } + public string CodDes { get; set; } + public string Tipologia { get; set; } + public string RagSocCliente { get; set; } + public string PartitaIva { get; set; } + public string CodiceFiscale { get; set; } + public string RagSocDestinazione { get; set; } + public string Indirizzo { get; set; } + public string NumeroCivico { get; set; } + public string Istat { get; set; } + public string Comune { get; set; } + public string Provincia { get; set; } + public string CodRegione { get; set; } + public string Regione { get; set; } + public string Cap { get; set; } + public string Telefono { get; set; } + public string Agente { get; set; } + public string DescrizioneAgente { get; set; } + public string CapoArea { get; set; } + public string DescrizioneCapoArea { get; set; } + public string MailFatturazione { get; set; } + public string DataCreazione { get; set; } + public string DataUltimoOrdine { get; set; } + public string DataUltimaFattura { get; set; } + public string CoordX { get; set; } + public string CoordY { get; set; } + +} diff --git a/StandManager/Model/DestinazioneViewModel.cs b/StandManager/Model/DestinazioneViewModel.cs index cd0b492..9c8dea2 100644 --- a/StandManager/Model/DestinazioneViewModel.cs +++ b/StandManager/Model/DestinazioneViewModel.cs @@ -21,6 +21,8 @@ public class DestinazioneViewModel public UtenteViewModel Agente { get; set; } public List Referenti { get; set; } + public string Info => $"{RagioneSociale} - {Citta}(), {Indirizzo}"; + public static implicit operator DestinazioneViewModel(Destinazione model) { return model == null diff --git a/StandManager/Model/InvitoEventoViewModel.cs b/StandManager/Model/InvitoEventoViewModel.cs index 1b23994..86cdc46 100644 --- a/StandManager/Model/InvitoEventoViewModel.cs +++ b/StandManager/Model/InvitoEventoViewModel.cs @@ -24,7 +24,8 @@ namespace StandManager.Model CodiceFornito = model.CodiceFornito, EventoId = model.EventoId, Id = model.Id, - IscrizioniEvento = model.IscrizioniEvento?.Select(x => (IscrizioneEventoViewModel)x).ToList() + IscrizioniEvento = model.IscrizioniEvento?.Select(x => (IscrizioneEventoViewModel)x).ToList(), + RagioneSociale = model.Cliente?.RagioneSociale }; } } diff --git a/StandManager/Model/ReferenteViewModel.cs b/StandManager/Model/ReferenteViewModel.cs index 4467903..e8d9c04 100644 --- a/StandManager/Model/ReferenteViewModel.cs +++ b/StandManager/Model/ReferenteViewModel.cs @@ -9,7 +9,7 @@ public class ReferenteViewModel public string Cognome { get; set; } public string Email { get; set; } public string NumeroTelefono { get; set; } - public Ruolo Ruolo { get; set; } + public RuoloReferente Ruolo { get; set; } public string RuoloNote { get; set; } public static implicit operator ReferenteViewModel(Referente model)