using Gestor.Model.Common; using Gestor.Model.Domain.Generic; using Gestor.Model.Helper; using Gestor.Model.Resources; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; namespace Gestor.Model.Domain.Seguros { public class Perfil : DomainBase, IDomain { private string _nome; private string _cepCirculacao; private string _cepPernoite; public Antifurto? AntiFurto { get; set; } public string CepCirculacao { get { return this._cepCirculacao; } set { this._cepCirculacao = value; } } public string CepPernoite { get { return this._cepPernoite; } set { this._cepPernoite = value; } } public Gestor.Model.Domain.Seguros.Cliente Cliente { get; set; } public Gestor.Model.Domain.Seguros.Controle Controle { get; set; } public string Cpf { get; set; } public DistanciaTrabalho? DistanciaResidenciaTrabalho { get; set; } public Gestor.Model.Common.EstadoCivil? EstadoCivil { get; set; } public bool? EstenderCobertura { get; set; } public GaragemTrabalhoEstudo? GaragemEstudo { get; set; } public Gestor.Model.Common.GaragemResidencia? GaragemResidencia { get; set; } public GaragemTrabalhoEstudo? GaragemTrabalho { get; set; } public string Habilitacao { get; set; } public bool? Isencao { get; set; } public string KmMensal { get; set; } public DateTime? Nascimento { get; set; } public string Nome { get { string str = this._nome; if (str != null) { return str.ToUpper(); } return null; } set { this._nome = value; } } public Gestor.Model.Common.Ocupacao? Ocupacao { get; set; } public Gestor.Model.Common.Relacao? Relacao { get; set; } public bool? SeguroVida { get; set; } public Gestor.Model.Common.Sexo? Sexo { get; set; } public Gestor.Model.Common.TempoHabilitacao? TempoHabilitacao { get; set; } public Gestor.Model.Common.TipoResidencia? TipoResidencia { get; set; } public UsoDependetes? UsoDependentes { get; set; } public bool? UsoProfissional { get; set; } [JsonIgnore] public Func>> ValidationEvent { get { Perfil perfil = this; return new Func>>(perfil.Validate); } } public int? VeiculoResidencia { get; set; } public Perfil() { } public List> Validate() { bool length; bool flag; List> keyValuePairs = ValidationHelper.AddValue(); if (this.Nascimento.HasValue && (DateTime.Compare(this.Nascimento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Nascimento.Value, new DateTime(9999, 12, 31)) > 0)) { keyValuePairs.AddValue("Nascimento", string.Format(Messages.DataInvalida, Array.Empty()), true); } if (string.IsNullOrWhiteSpace(this.Nome)) { keyValuePairs.AddValue("Nome", Messages.Obrigatorio, true); } else if (this.Nome.Length > 255) { keyValuePairs.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 255), true); } string kmMensal = this.KmMensal; if (kmMensal != null) { length = kmMensal.Length > 5; } else { length = false; } if (length) { keyValuePairs.AddValue("KmMensal", string.Format(Messages.MaiorQueLimite, 5), true); } string habilitacao = this.Habilitacao; if (habilitacao != null) { flag = habilitacao.Length > 15; } else { flag = false; } if (flag) { keyValuePairs.AddValue("Habilitacao", string.Format(Messages.MaiorQueLimite, 15), true); } if (!this.Relacao.HasValue) { keyValuePairs.AddValue("Relacao", Messages.Obrigatorio, true); } if (!string.IsNullOrWhiteSpace(this.Cpf) && !this.Cpf.ValidacaoDocumento()) { keyValuePairs.AddValue("Cpf", Messages.Invalido, true); } if (!string.IsNullOrWhiteSpace(this.CepPernoite) && !this.CepPernoite.FormataCep().ValidacaoCep()) { keyValuePairs.AddValue("CepPernoite", Messages.Invalido, true); } if (!string.IsNullOrWhiteSpace(this.CepCirculacao) && !this.CepCirculacao.FormataCep().ValidacaoCep()) { keyValuePairs.AddValue("CepCirculacao", Messages.Invalido, true); } return keyValuePairs; } } }