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; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.CompilerServices; 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 Documento { get { string str = this._documento; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._documento = value; } } public string Email { get { string str = this._email; if (str == null) { return null; } return str.ToLower().Trim(); } set { this._email = value; } } public string EmailResponsavel { get { string str = this._emailResponsavel; if (str == null) { return null; } return str.ToLower().Trim(); } set { this._emailResponsavel = value; } } public string Facebook { get; set; } public string Instagram { get; set; } public string Linkdin { get; set; } public string Localizacao { get; set; } public byte[] Logo { get; set; } public string LogoId { get; set; } public int MaxFileSize { get; set; } public string Nome { get { string str = this._nome; if (str != null) { return str.ToUpper(); } return null; } set { this._nome = value; } } public string NomeSocial { get; set; } public string PrimeiroPrefixo { get { string str = this._primeiroPrefixo; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._primeiroPrefixo = value; } } public string PrimeiroTelefone { get { string str = this._primeiroTelefone; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._primeiroTelefone = value; } } public string QuantidadeFiliais { get { string str = this._quantidadeFiliais; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._quantidadeFiliais = value; } } public long QuantidadeFuncionarios { get; set; } public string Responsavel { get { string str = this._responsavel; if (str != null) { return str.ToUpper(); } return null; } set { this._responsavel = value; } } public string SegundoPrefixo { get { string str = this._segundoPrefixo; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._segundoPrefixo = value; } } public string SegundoTelefone { get { string str = this._segundoTelefone; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._segundoTelefone = value; } } public string SenhaAdmin { get; set; } public string Serial { get { string str = this._serial; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._serial = value; } } public string Site { get { string str = this._site; if (str != null) { return str.Trim(); } return null; } set { this._site = value; } } public TipoTelefone TipoTelefone1 { get { if (this._tipo1.HasValue) { TipoTelefone? nullable = this._tipo1; if (!((int)nullable.GetValueOrDefault() == 0 & nullable.HasValue)) { return this._tipo1.Value; } } return TipoTelefone.Comercial; } set { this._tipo1 = new TipoTelefone?(value); } } public TipoTelefone TipoTelefone2 { get { if (this._tipo2.HasValue) { TipoTelefone? nullable = this._tipo2; if (!((int)nullable.GetValueOrDefault() == 0 & nullable.HasValue)) { return this._tipo2.Value; } } return TipoTelefone.Comercial; } set { this._tipo2 = new TipoTelefone?(value); } } public string Twitter { get; set; } [JsonIgnore] public Func>> ValidationEvent { get { Empresa empresa = this; return new Func>>(empresa.Validate); } } public string Whatsapp { get; set; } public string WhatsappSinistro { get; set; } public Empresa() { } public List Log() { List tupleLists = new List(); TupleList tupleList = new TupleList(); ObservableCollection> observableCollection = new ObservableCollection>() { new Tuple("DOCUMENTO (CPF/CNPJ)", (string.IsNullOrWhiteSpace(this.Documento) ? "" : this.Documento), ""), new Tuple("NÚMERO DE SÉRIE", (string.IsNullOrWhiteSpace(this.Serial) ? "" : this.Serial), ""), new Tuple("NOME", (string.IsNullOrWhiteSpace(this.Nome) ? "" : this.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(this.Site) ? "" : this.Site), ""), new Tuple("E-MAIL", (string.IsNullOrWhiteSpace(this.Email) ? "" : this.Email), ""), new Tuple("PRIMEIRO PREFIXO", (string.IsNullOrWhiteSpace(this.PrimeiroPrefixo) ? "" : this.PrimeiroPrefixo), ""), new Tuple("PRIMEIRO TELEFONE", (string.IsNullOrWhiteSpace(this.PrimeiroTelefone) ? "" : this.PrimeiroTelefone), ""), new Tuple("SEGUNDO PREFIXO", (string.IsNullOrWhiteSpace(this.SegundoPrefixo) ? "" : this.SegundoPrefixo), ""), new Tuple("SEGUNDO TELEFONE", (string.IsNullOrWhiteSpace(this.SegundoTelefone) ? "" : this.SegundoTelefone), ""), new Tuple("E-MAIL", (string.IsNullOrWhiteSpace(this.Email) ? "" : this.Email), "") }; long quantidadeFuncionarios = this.QuantidadeFuncionarios; observableCollection.Add(new Tuple("NÚMERO DE FUNCIONÁRIOS", quantidadeFuncionarios.ToString(), "")); observableCollection.Add(new Tuple("RESPONSÁVEL FINANCEIRO", (string.IsNullOrWhiteSpace(this.Responsavel) ? "" : this.Responsavel), "")); observableCollection.Add(new Tuple("E-MAIL DO RESPONSÁVEL", (string.IsNullOrWhiteSpace(this.EmailResponsavel) ? "" : this.EmailResponsavel), "")); tupleList.Tuples = observableCollection; tupleLists.Add(tupleList); return tupleLists; } public List> Validate() { List> keyValuePairs = ValidationHelper.AddValue(); if (string.IsNullOrWhiteSpace(this.Documento)) { keyValuePairs.AddValue("Documento", Messages.Obrigatorio, true); } else if (!this.Documento.ValidacaoDocumento()) { keyValuePairs.AddValue("Documento", Messages.Invalido, true); } if (string.IsNullOrWhiteSpace(this.Serial)) { keyValuePairs.AddValue("Serial", Messages.Obrigatorio, true); } else if (this.Serial.Length > 18) { keyValuePairs.AddValue("Serial", string.Format(Messages.MaiorQueLimite, 18), true); } if (!string.IsNullOrWhiteSpace(this.Site) && this.Site.Length > 80) { keyValuePairs.AddValue("Site", string.Format(Messages.MaiorQueLimite, 80), true); } if (!string.IsNullOrWhiteSpace(this.SenhaAdmin) && this.SenhaAdmin.Length > 90) { keyValuePairs.AddValue("SenhaAdmin", string.Format(Messages.MaiorQueLimite, 90), true); } if (string.IsNullOrWhiteSpace(this.Nome)) { keyValuePairs.AddValue("Nome", Messages.Obrigatorio, true); } else if (this.Nome.Length > 60) { keyValuePairs.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 60), true); } if (string.IsNullOrWhiteSpace(base.Cep)) { keyValuePairs.AddValue("Cep", Messages.Obrigatorio, true); } else if (!base.Cep.ValidacaoCep()) { keyValuePairs.AddValue("Cep", Messages.Invalido, true); } if (string.IsNullOrWhiteSpace(base.Endereco)) { keyValuePairs.AddValue("Endereco", Messages.Obrigatorio, true); } else if (base.Endereco.Length > 60) { keyValuePairs.AddValue("Endereco", string.Format(Messages.MaiorQueLimite, 60), true); } if (string.IsNullOrWhiteSpace(base.Numero)) { keyValuePairs.AddValue("Numero", Messages.Obrigatorio, true); } else if (base.Numero.Length > 10) { keyValuePairs.AddValue("Numero", string.Format(Messages.MaiorQueLimite, 10), true); } if (!string.IsNullOrWhiteSpace(base.Complemento) && base.Complemento.Length > 100) { keyValuePairs.AddValue("Complemento", string.Format(Messages.MaiorQueLimite, 100), true); } if (string.IsNullOrWhiteSpace(base.Bairro)) { keyValuePairs.AddValue("Bairro", Messages.Obrigatorio, true); } else if (base.Bairro.Length > 150) { keyValuePairs.AddValue("Bairro", string.Format(Messages.MaiorQueLimite, 150), true); } if (string.IsNullOrWhiteSpace(base.Cidade)) { keyValuePairs.AddValue("Cidade", Messages.Obrigatorio, true); } else if (base.Cidade.Length > 30) { keyValuePairs.AddValue("Cidade", string.Format(Messages.MaiorQueLimite, 30), true); } if (string.IsNullOrWhiteSpace(base.Estado)) { keyValuePairs.AddValue("Estado", Messages.Obrigatorio, true); } else if (!base.Estado.ValidacaoEstado()) { keyValuePairs.AddValue("Estado", Messages.Invalido, true); } if (string.IsNullOrWhiteSpace(this.Email)) { keyValuePairs.AddValue("Email", Messages.Obrigatorio, true); } else if (!this.Email.ValidacaoEmail()) { keyValuePairs.AddValue("Email", Messages.Invalido, true); } else if (this.Email.Length > 50) { keyValuePairs.AddValue("Email", string.Format(Messages.MaiorQueLimite, 50), true); } if (string.IsNullOrWhiteSpace(this.EmailResponsavel)) { keyValuePairs.AddValue("EmailResponsavel", Messages.Obrigatorio, true); } else if (!this.EmailResponsavel.ValidacaoEmail()) { keyValuePairs.AddValue("EmailResponsavel", Messages.Invalido, true); } else if (this.EmailResponsavel.Length > 50) { keyValuePairs.AddValue("EmailResponsavel", string.Format(Messages.MaiorQueLimite, 50), true); } if (!string.IsNullOrEmpty(this.Facebook) && !this.Facebook.Contains("http")) { this.Facebook = string.Concat("https://", this.Facebook.Trim()); } if (!string.IsNullOrEmpty(this.Instagram) && !this.Instagram.Contains("http")) { this.Instagram = string.Concat("https://", this.Instagram.Trim()); } if (!string.IsNullOrEmpty(this.Linkdin) && !this.Linkdin.Contains("http")) { this.Linkdin = string.Concat("https://", this.Linkdin.Trim()); } if (!string.IsNullOrEmpty(this.Twitter) && !this.Twitter.Contains("http")) { this.Twitter = string.Concat("https://", this.Twitter.Trim()); } if (!string.IsNullOrEmpty(this.Site) && !this.Site.Contains("http")) { this.Site = string.Concat("http://", this.Site.Trim()); } return keyValuePairs; } } }