using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Gestor.Model.Common; using Gestor.Model.Domain.Generic; using Gestor.Model.Domain.Seguros; using Gestor.Model.Helper; using Gestor.Model.Resources; using Newtonsoft.Json; namespace Gestor.Model.Domain.Common; public class Empresa : EnderecoBase, IDomain { private string _nome; private string _documento; private string _serial; private string _site; private string _email; private string _primeiroPrefixo; private string _primeiroTelefone; private string _segundoPrefixo; private string _segundoTelefone; private string _quantidadeFiliais; private string _responsavel; private string _emailResponsavel; private TipoTelefone? _tipo1; private TipoTelefone? _tipo2; public string Nome { get { return _nome?.ToUpper(); } set { _nome = value; } } public string NomeSocial { get; set; } public string Documento { get { return _documento?.ToUpper().Trim(); } set { _documento = value; } } public string Serial { get { return _serial?.ToUpper().Trim(); } set { _serial = value; } } public TipoTelefone TipoTelefone1 { get { if (!_tipo1.HasValue || _tipo1 == (TipoTelefone)0) { return TipoTelefone.Comercial; } return _tipo1.Value; } set { _tipo1 = value; } } public TipoTelefone TipoTelefone2 { get { if (!_tipo2.HasValue || _tipo2 == (TipoTelefone)0) { return TipoTelefone.Comercial; } return _tipo2.Value; } set { _tipo2 = value; } } public string Site { get { return _site?.Trim(); } set { _site = value; } } public string Email { get { return _email?.ToLower().Trim(); } set { _email = value; } } public string PrimeiroPrefixo { get { return _primeiroPrefixo?.ToUpper().Trim(); } set { _primeiroPrefixo = value; } } public string PrimeiroTelefone { get { return _primeiroTelefone?.ToUpper().Trim(); } set { _primeiroTelefone = value; } } public string SegundoPrefixo { get { return _segundoPrefixo?.ToUpper().Trim(); } set { _segundoPrefixo = value; } } public string SegundoTelefone { get { return _segundoTelefone?.ToUpper().Trim(); } set { _segundoTelefone = value; } } public long QuantidadeFuncionarios { get; set; } public string QuantidadeFiliais { get { return _quantidadeFiliais?.ToUpper().Trim(); } set { _quantidadeFiliais = value; } } public string Responsavel { get { return _responsavel?.ToUpper(); } set { _responsavel = value; } } public string EmailResponsavel { get { return _emailResponsavel?.ToLower().Trim(); } set { _emailResponsavel = value; } } public string SenhaAdmin { get; set; } public string Facebook { get; set; } public string Instagram { get; set; } public string Linkdin { get; set; } public string Whatsapp { get; set; } public string WhatsappSinistro { get; set; } public string Twitter { get; set; } public string Localizacao { get; set; } public byte[] Logo { get; set; } public string LogoId { get; set; } public int MaxFileSize { get; set; } [JsonIgnore] public Func>> ValidationEvent => Validate; public List> Validate() { List> list = ValidationHelper.AddValue(); if (string.IsNullOrWhiteSpace(Documento)) { list.AddValue("Documento", Messages.Obrigatorio); } else if (!Documento.ValidacaoDocumento()) { list.AddValue("Documento", Messages.Invalido); } if (string.IsNullOrWhiteSpace(Serial)) { list.AddValue("Serial", Messages.Obrigatorio); } else if (Serial.Length > 18) { list.AddValue("Serial", string.Format(Messages.MaiorQueLimite, 18)); } if (!string.IsNullOrWhiteSpace(Site) && Site.Length > 80) { list.AddValue("Site", string.Format(Messages.MaiorQueLimite, 80)); } if (!string.IsNullOrWhiteSpace(SenhaAdmin) && SenhaAdmin.Length > 90) { list.AddValue("SenhaAdmin", string.Format(Messages.MaiorQueLimite, 90)); } if (string.IsNullOrWhiteSpace(Nome)) { list.AddValue("Nome", Messages.Obrigatorio); } else if (Nome.Length > 60) { list.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 60)); } if (string.IsNullOrWhiteSpace(base.Cep)) { list.AddValue("Cep", Messages.Obrigatorio); } else if (!base.Cep.ValidacaoCep()) { list.AddValue("Cep", Messages.Invalido); } if (string.IsNullOrWhiteSpace(base.Endereco)) { list.AddValue("Endereco", Messages.Obrigatorio); } else if (base.Endereco.Length > 60) { list.AddValue("Endereco", string.Format(Messages.MaiorQueLimite, 60)); } if (string.IsNullOrWhiteSpace(base.Numero)) { list.AddValue("Numero", Messages.Obrigatorio); } else if (base.Numero.Length > 10) { list.AddValue("Numero", string.Format(Messages.MaiorQueLimite, 10)); } if (!string.IsNullOrWhiteSpace(base.Complemento) && base.Complemento.Length > 100) { list.AddValue("Complemento", string.Format(Messages.MaiorQueLimite, 100)); } if (string.IsNullOrWhiteSpace(base.Bairro)) { list.AddValue("Bairro", Messages.Obrigatorio); } else if (base.Bairro.Length > 150) { list.AddValue("Bairro", string.Format(Messages.MaiorQueLimite, 150)); } if (string.IsNullOrWhiteSpace(base.Cidade)) { list.AddValue("Cidade", Messages.Obrigatorio); } else if (base.Cidade.Length > 30) { list.AddValue("Cidade", string.Format(Messages.MaiorQueLimite, 30)); } if (string.IsNullOrWhiteSpace(base.Estado)) { list.AddValue("Estado", Messages.Obrigatorio); } else if (!base.Estado.ValidacaoEstado()) { list.AddValue("Estado", Messages.Invalido); } if (string.IsNullOrWhiteSpace(Email)) { list.AddValue("Email", Messages.Obrigatorio); } else if (!Email.ValidacaoEmail()) { list.AddValue("Email", Messages.Invalido); } else if (Email.Length > 50) { list.AddValue("Email", string.Format(Messages.MaiorQueLimite, 50)); } if (string.IsNullOrWhiteSpace(EmailResponsavel)) { list.AddValue("EmailResponsavel", Messages.Obrigatorio); } else if (!EmailResponsavel.ValidacaoEmail()) { list.AddValue("EmailResponsavel", Messages.Invalido); } else if (EmailResponsavel.Length > 50) { list.AddValue("EmailResponsavel", string.Format(Messages.MaiorQueLimite, 50)); } if (!string.IsNullOrEmpty(Facebook) && !Facebook.Contains("http")) { Facebook = "https://" + Facebook.Trim(); } if (!string.IsNullOrEmpty(Instagram) && !Instagram.Contains("http")) { Instagram = "https://" + Instagram.Trim(); } if (!string.IsNullOrEmpty(Linkdin) && !Linkdin.Contains("http")) { Linkdin = "https://" + Linkdin.Trim(); } if (!string.IsNullOrEmpty(Twitter) && !Twitter.Contains("http")) { Twitter = "https://" + Twitter.Trim(); } if (!string.IsNullOrEmpty(Site) && !Site.Contains("http")) { Site = "http://" + Site.Trim(); } return list; } public List Log() { return new List { new TupleList { Tuples = new ObservableCollection> { new Tuple("DOCUMENTO (CPF/CNPJ)", string.IsNullOrWhiteSpace(Documento) ? "" : Documento, ""), new Tuple("NÚMERO DE SÉRIE", string.IsNullOrWhiteSpace(Serial) ? "" : Serial, ""), new Tuple("NOME", string.IsNullOrWhiteSpace(Nome) ? "" : Nome, ""), new Tuple("CEP", string.IsNullOrWhiteSpace(base.Cep) ? "" : base.Cep, ""), new Tuple("ENDEREÇO", string.IsNullOrWhiteSpace(base.Endereco) ? "" : base.Endereco, ""), new Tuple("NÚMERO", string.IsNullOrWhiteSpace(base.Numero) ? "" : base.Numero, ""), new Tuple("BAIRRO", string.IsNullOrWhiteSpace(base.Bairro) ? "" : base.Bairro, ""), new Tuple("CIDADE", string.IsNullOrWhiteSpace(base.Cidade) ? "" : base.Cidade, ""), new Tuple("ESTADO", string.IsNullOrWhiteSpace(base.Estado) ? "" : base.Estado, ""), new Tuple("SITE", string.IsNullOrWhiteSpace(Site) ? "" : Site, ""), new Tuple("E-MAIL", string.IsNullOrWhiteSpace(Email) ? "" : Email, ""), new Tuple("PRIMEIRO PREFIXO", string.IsNullOrWhiteSpace(PrimeiroPrefixo) ? "" : PrimeiroPrefixo, ""), new Tuple("PRIMEIRO TELEFONE", string.IsNullOrWhiteSpace(PrimeiroTelefone) ? "" : PrimeiroTelefone, ""), new Tuple("SEGUNDO PREFIXO", string.IsNullOrWhiteSpace(SegundoPrefixo) ? "" : SegundoPrefixo, ""), new Tuple("SEGUNDO TELEFONE", string.IsNullOrWhiteSpace(SegundoTelefone) ? "" : SegundoTelefone, ""), new Tuple("E-MAIL", string.IsNullOrWhiteSpace(Email) ? "" : Email, ""), new Tuple("NÚMERO DE FUNCIONÁRIOS", QuantidadeFuncionarios.ToString(), ""), new Tuple("RESPONSÁVEL FINANCEIRO", string.IsNullOrWhiteSpace(Responsavel) ? "" : Responsavel, ""), new Tuple("E-MAIL DO RESPONSÁVEL", string.IsNullOrWhiteSpace(EmailResponsavel) ? "" : EmailResponsavel, "") } } }; } }