60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using StandManager.Domain.Entita;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace StandManager.Model;
|
|
public class DestinazioneViewModel
|
|
{
|
|
public Guid Id { get; set; }
|
|
[Required(ErrorMessage = "La ragione sociale è obbligatoria")]
|
|
public string RagioneSociale { get; set; }
|
|
[Required(ErrorMessage = "La Partita IVA")]
|
|
public string PartitaIva { get; set; }
|
|
public string Cap { get; set; }
|
|
public string Citta { get; set; }
|
|
public string Indirizzo { get; set; }
|
|
public string Email { get; set; }
|
|
public string EmailInvito { get; set; }
|
|
public string NumeroTelefono { get; set; }
|
|
public Guid? AgenteId { get; set; }
|
|
public string NomeAgente { get; set; }
|
|
public UtenteViewModel Agente { get; set; }
|
|
public List<ReferenteViewModel> Referenti { get; set; }
|
|
|
|
public static implicit operator DestinazioneViewModel(Destinazione model)
|
|
{
|
|
return model == null
|
|
? null
|
|
: new DestinazioneViewModel()
|
|
{
|
|
NomeAgente = model.Agente?.ToString(),
|
|
Agente = model.Agente,
|
|
AgenteId = model.Agente?.Id,
|
|
Cap = model.Cap,
|
|
Citta = model.Citta,
|
|
Email = model.Email,
|
|
EmailInvito = model.EmailInvito,
|
|
Id = model.Id,
|
|
Indirizzo = model.Indirizzo,
|
|
NumeroTelefono = model.NumeroTelefono,
|
|
PartitaIva = model.PartitaIva,
|
|
RagioneSociale = model.RagioneSociale,
|
|
Referenti = model.Referenti?.Select(x => (ReferenteViewModel)x).ToList() ?? new List<ReferenteViewModel>()
|
|
};
|
|
}
|
|
|
|
public Destinazione Map(Destinazione model)
|
|
{
|
|
model.RagioneSociale = RagioneSociale;
|
|
model.PartitaIva = PartitaIva;
|
|
model.Cap = Cap;
|
|
model.Citta = Citta;
|
|
model.Indirizzo = Indirizzo;
|
|
model.Email = Email;
|
|
model.EmailInvito = EmailInvito;
|
|
model.NumeroTelefono = NumeroTelefono;
|
|
|
|
return model;
|
|
}
|
|
}
|