Files
StandManager/StandManager/Model/IscrizioneEventoViewModel.cs
2025-12-22 15:38:12 +01:00

100 lines
3.9 KiB
C#

using StandManager.Domain.Entita;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace StandManager.Model;
public class IscrizioneEventoViewModel
{
public Guid Id { get; set; }
public EventoViewModel Evento { get; set; }
public InvitoEvento InvitoEvento { get; set; }
public ClienteViewModel Cliente { get; set; }
public Guid? ClienteId { get; set; }
public Guid? DestinazioneId { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "Inserire un numero di partecipanti valido")]
public int Partecipanti { get; set; }
public string? Note { get; set; }
public bool ScanCompleto { get; set; }
public DateTime? DataScan { get; set; }
[Required(ErrorMessage = "Il nome è obbigatorio")]
public string Nome { get; set; }
[Required(ErrorMessage = "Il cognome è obbigatorio")]
public string Cognome { get; set; }
[Required(ErrorMessage = "La E-mail è obbigatoria")]
public string Email { get; set; }
[Required(ErrorMessage = "Il numero di telefono è obbigatorio")]
public string NumeroTelefono { get; set; }
[Required(ErrorMessage = "La provincia è obbigatoria")]
public Guid Provincia { get; set; }
[Required(ErrorMessage = "Il comune è obbigatorio")]
public string Comune { get; set; }
[Required(ErrorMessage = "Il CAP è obbigatorio")]
public string Cap { get; set; }
[Required(ErrorMessage = "La Ragione Sociale è obbigatoria")]
public string RagioneSociale { get; set; }
[Required(ErrorMessage = "Il campo è obbigatorio")]
public string EsperienzaConDAC { get; set; }
[Required(ErrorMessage = "La tipologia è obbigatoria")]
public Guid? TipologiaClienteId { get; set; }
public RuoloTipo Ruolo { get; set; }
[Required(ErrorMessage = "Il ruolo è obbigatorio")]
public int? RuoloInt { get; set; }
public string? PartitaIva { get; set; }
[Required(ErrorMessage = "E' necessario indicare la data di partecipazione")]
public DateTime? GiornoPresenza { 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;
model.NumeroTelefono = NumeroTelefono;
/*model.Provincia = Provincia;*/
model.Comune = Comune;
model.Cap = Cap;
model.RagioneSociale = RagioneSociale;
model.EsperienzaConDAC = EsperienzaConDAC;
model.PartitaIva = PartitaIva;
model.GiornoPresenza = GiornoPresenza.Value;
return model;
}
public static implicit operator IscrizioneEventoViewModel(IscrizioneEvento model)
{
return model == null
? null
: new IscrizioneEventoViewModel()
{
Id = model.Id,
InvitoEvento = model.InvitoEvento,
DestinazioneId = model.DestinazioneId,
ClienteId = model.Cliente?.Id,
Partecipanti = model.Partecipanti,
Note = model.Note,
ScanCompleto = model.ScanCompleto,
DataScan = model.DataScan,
Nome = model.Nome,
Cognome = model.Cognome,
Email = model.Email,
NumeroTelefono = model.NumeroTelefono,
Provincia = model.Provincia?.Id ?? Guid.Empty,
Comune = model.Comune,
Cap = model.Cap,
RagioneSociale = model.RagioneSociale,
EsperienzaConDAC = model.EsperienzaConDAC,
TipologiaClienteId = model.TipologiaClienteId,
Ruolo = model.Ruolo,
RuoloInt = (int?)model.Ruolo,
PartitaIva = model.PartitaIva,
GiornoPresenza = model.GiornoPresenza
};
}
}