From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Gestor.Model/Model.Domain.Seguros/Usuario.cs | 872 +++++++++++++++++++++ 1 file changed, 872 insertions(+) create mode 100644 Codemerx/Gestor.Model/Model.Domain.Seguros/Usuario.cs (limited to 'Codemerx/Gestor.Model/Model.Domain.Seguros/Usuario.cs') diff --git a/Codemerx/Gestor.Model/Model.Domain.Seguros/Usuario.cs b/Codemerx/Gestor.Model/Model.Domain.Seguros/Usuario.cs new file mode 100644 index 0000000..39c6cc1 --- /dev/null +++ b/Codemerx/Gestor.Model/Model.Domain.Seguros/Usuario.cs @@ -0,0 +1,872 @@ +using Gestor.Model.API; +using Gestor.Model.Attributes; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Helper; +using Gestor.Model.Resources; +using Gestor.Model.Validation; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; + +namespace Gestor.Model.Domain.Seguros +{ + public class Usuario : EnderecoBase, IDomain + { + private string _nome; + + private string _prefixo; + + private string _telefone; + + private string _prefixo2; + + private string _telefone2; + + private string _email; + + private string _documento; + + private string _identidade; + + private string _estadoEmissor; + + private string _agencia; + + private string _conta; + + private string _login; + + private bool? _segunda; + + private bool? _terca; + + private bool? _quarta; + + private bool? _quinta; + + private bool? _sexta; + + private bool? _sabado; + + private bool? _domingo; + + private bool? _dashboard; + + private TipoTelaInicial? _telaInicial; + + [Log(true)] + public bool Administrador + { + get; + set; + } + + [Description("PERMISSÃO ADMINISTRADOR CENTRAL SEGURADO")] + [Log(true)] + public bool AdministradorCentralSegurado + { + get; + set; + } + + [Description("AGÊNCIA")] + [Log(true)] + public string Agencia + { + get + { + string str = this._agencia; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._agencia = value; + } + } + + public bool Aggilizador + { + get; + set; + } + + [Log(true)] + public Gestor.Model.Domain.Common.Banco Banco + { + get; + set; + } + + [Log(true)] + public string Cargo + { + get; + set; + } + + [Log(true)] + public string Conta + { + get + { + string str = this._conta; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._conta = value; + } + } + + [Description("ACESSO AO DASHBOARD")] + [Log(true)] + public bool? Dashboard + { + get + { + return this._dashboard; + } + set + { + this._dashboard = new bool?(value.GetValueOrDefault(true)); + } + } + + [Log(true)] + public string Documento + { + get + { + string str = this._documento; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._documento = value; + } + } + + [Description("ACESSO AOS DOMINGOS")] + [Log(true)] + public bool? Domingo + { + get + { + return this._domingo; + } + set + { + this._domingo = new bool?(value.GetValueOrDefault(true)); + } + } + + [Log(true)] + public string Email + { + get + { + string str = this._email; + if (str == null) + { + return null; + } + return str.ToLower().Trim(); + } + set + { + this._email = value; + } + } + + [Description("ESTADO EMISSOR")] + [Log(true)] + public string EstadoEmissor + { + get + { + string str = this._estadoEmissor; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._estadoEmissor = value; + } + } + + public bool Excluido + { + get; + set; + } + + [Description("DATA DE EXPEDIÇÃO")] + [Log(true)] + public DateTime? Expedicao + { + get; + set; + } + + [Description("FILTRO INICIAL")] + [Log(true)] + public TipoFiltroCliente? FiltroInicial + { + get; + set; + } + + [Description("FIM DO ACESSO")] + public DateTime? FimAcesso + { + get; + set; + } + + public long IdEmpresa + { + get; + set; + } + + [Log(true)] + public string Identidade + { + get + { + string str = this._identidade; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._identidade = value; + } + } + + [Description("INÍCIO DO ACESSO")] + public DateTime? InicioAcesso + { + get; + set; + } + + [Log(true)] + public string Login + { + get + { + string str = this._login; + if (str != null) + { + return str.ToUpper(); + } + return null; + } + set + { + this._login = value; + } + } + + [Description("ACESSO AO MOBILE")] + [Log(true)] + public bool Mobile + { + get; + set; + } + + [Description("DATA DE NASCIMENTO")] + [Log(true)] + public DateTime? Nascimento + { + get; + set; + } + + [Log(true)] + [Name(true)] + public string Nome + { + get + { + return this._nome; + } + set + { + this._nome = value; + } + } + + [Description("PERMISSÃO ACESSO AGGILIZADOR")] + [Log(true)] + public long? PermissaoAggilizador + { + get; + set; + } + + [Description("PREFIXO TELEFONE 1")] + [Log(true)] + public string Prefixo + { + get + { + string str = this._prefixo; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._prefixo = value; + } + } + + [Description("PREFIXO TELEFONE 2")] + [Log(true)] + public string Prefixo2 + { + get + { + string str = this._prefixo2; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._prefixo2 = value; + } + } + + [Description("ACESSO ÁS QUARTAS-FEIRAS")] + [Log(true)] + public bool? Quarta + { + get + { + return this._quarta; + } + set + { + this._quarta = new bool?(value.GetValueOrDefault(true)); + } + } + + [Description("ACESSO ÁS QUINTAS-FEIRAS")] + [Log(true)] + public bool? Quinta + { + get + { + return this._quinta; + } + set + { + this._quinta = new bool?(value.GetValueOrDefault(true)); + } + } + + [Description("ACESSO AOS RESULTADOS MOBILE")] + [Log(true)] + public bool Resultados + { + get; + set; + } + + [Description("ACESSO AOS SÁBADOS")] + [Log(true)] + public bool? Sabado + { + get + { + return this._sabado; + } + set + { + this._sabado = new bool?(value.GetValueOrDefault(true)); + } + } + + [Description("ACESSO ÀS SEGUNDAS-FEIRAS")] + [Log(true)] + public bool? Segunda + { + get + { + return this._segunda; + } + set + { + this._segunda = new bool?(value.GetValueOrDefault(true)); + } + } + + public bool Selecionado + { + get; + set; + } + + public string Senha + { + get; + set; + } + + public string SenhaAnterior { get; set; } = string.Empty; + + [Log(true)] + public Gestor.Model.Common.Sexo Sexo + { + get; + set; + } + + [Description("ACESSO ÁS SEXTAS-FEIRAS")] + [Log(true)] + public bool? Sexta + { + get + { + return this._sexta; + } + set + { + this._sexta = new bool?(value.GetValueOrDefault(true)); + } + } + + public string SsoId + { + get; + set; + } + + [Log(true)] + public TipoTelaInicial? TelaInicial + { + get + { + return new TipoTelaInicial?(this._telaInicial.GetValueOrDefault()); + } + set + { + this._telaInicial = new TipoTelaInicial?(value.GetValueOrDefault()); + } + } + + [Description("TELEFONE 1")] + [Log(true)] + public string Telefone + { + get + { + string str = this._telefone; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._telefone = value; + } + } + + [Description("TELEFONE 2")] + [Log(true)] + public string Telefone2 + { + get + { + string str = this._telefone2; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._telefone2 = value; + } + } + + [Description("ACESSO ÀS TERÇAS-FEIRAS")] + [Log(true)] + public bool? Terca + { + get + { + return this._terca; + } + set + { + this._terca = new bool?(value.GetValueOrDefault(true)); + } + } + + [Description("TIPO DO TELEFONE 1")] + [Log(true)] + public Gestor.Model.Common.TipoTelefone? TipoTelefone + { + get; + set; + } + + [Description("TIPO DO TELEFONE 2")] + [Log(true)] + public Gestor.Model.Common.TipoTelefone? TipoTelefone2 + { + get; + set; + } + + public string TokenSso + { + get; + set; + } + + [JsonIgnore] + public Func>> ValidationEvent + { + get + { + Usuario usuario = this; + return new Func>>(usuario.Validate); + } + } + + public string Visita + { + get; + set; + } + + public Usuario() + { + } + + public List Log() + { + string shortDateString; + string str; + string nome; + string shortTimeString; + string shortTimeString1; + List tupleLists = new List(); + TupleList tupleList = new TupleList(); + ObservableCollection> observableCollection = new ObservableCollection>() + { + new Tuple("NOME", (string.IsNullOrWhiteSpace(this.Nome) ? "" : this.Nome), ""), + new Tuple("CPF/CNPJ", (string.IsNullOrWhiteSpace(this.Documento) ? "" : this.Documento), ""), + new Tuple("USUÁRIO", (string.IsNullOrWhiteSpace(this.Login) ? "" : this.Login), ""), + new Tuple("IDENTIDADE", (string.IsNullOrWhiteSpace(this.Identidade) ? "" : this.Identidade), ""), + new Tuple("ESTADO EMISSOR", (string.IsNullOrWhiteSpace(this.EstadoEmissor) ? "" : this.EstadoEmissor), "") + }; + DateTime? expedicao = this.Expedicao; + if (!expedicao.HasValue) + { + shortDateString = ""; + } + else + { + expedicao = this.Expedicao; + if (expedicao.HasValue) + { + shortDateString = expedicao.GetValueOrDefault().ToShortDateString(); + } + else + { + shortDateString = null; + } + } + observableCollection.Add(new Tuple("DATA DE EXPEDIÇÃO", shortDateString, "")); + observableCollection.Add(new Tuple("SEXO", this.Sexo.GetDescription(), "")); + expedicao = this.Nascimento; + if (!expedicao.HasValue) + { + str = ""; + } + else + { + expedicao = this.Nascimento; + if (expedicao.HasValue) + { + str = expedicao.GetValueOrDefault().ToShortDateString(); + } + else + { + str = null; + } + } + observableCollection.Add(new Tuple("DATA DE NASCIMENTO", str, "")); + if (this.Banco == null) + { + nome = ""; + } + else + { + Gestor.Model.Domain.Common.Banco banco = this.Banco; + if (banco != null) + { + nome = banco.Nome; + } + else + { + nome = null; + } + } + observableCollection.Add(new Tuple("BANCO", nome, "")); + observableCollection.Add(new Tuple("AGÊNCIA", (string.IsNullOrWhiteSpace(this.Agencia) ? "" : this.Agencia), "")); + observableCollection.Add(new Tuple("CONTA", (string.IsNullOrWhiteSpace(this.Conta) ? "" : this.Conta), "")); + observableCollection.Add(new Tuple("ENDEREÇO", (string.IsNullOrWhiteSpace(base.Endereco) ? "" : base.Endereco), "")); + observableCollection.Add(new Tuple("NÚMERO", (string.IsNullOrWhiteSpace(base.Numero) ? "" : base.Numero), "")); + observableCollection.Add(new Tuple("COMPLEMENTO", (string.IsNullOrWhiteSpace(base.Complemento) ? "" : base.Complemento), "")); + observableCollection.Add(new Tuple("BAIRRO", (string.IsNullOrWhiteSpace(base.Bairro) ? "" : base.Bairro), "")); + observableCollection.Add(new Tuple("CIDADE", (string.IsNullOrWhiteSpace(base.Cidade) ? "" : base.Cidade), "")); + observableCollection.Add(new Tuple("ESTADO", (string.IsNullOrWhiteSpace(base.Estado) ? "" : base.Estado), "")); + observableCollection.Add(new Tuple("CEP", (string.IsNullOrWhiteSpace(base.Cep) ? "" : base.Cep), "")); + observableCollection.Add(new Tuple("TIPO TELEFONE", (!this.TipoTelefone.HasValue ? "" : this.TipoTelefone.GetDescription()), "")); + observableCollection.Add(new Tuple("PRIMEIRO PREFIXO", (string.IsNullOrWhiteSpace(this.Prefixo) ? "" : this.Prefixo), "")); + observableCollection.Add(new Tuple("PRIMEIRO TELEFONE", (string.IsNullOrWhiteSpace(this.Telefone) ? "" : this.Telefone), "")); + observableCollection.Add(new Tuple("TIPO TELEFONE", (!this.TipoTelefone2.HasValue ? "" : this.TipoTelefone2.GetDescription()), "")); + observableCollection.Add(new Tuple("SEGUNDO PREFIXO", (string.IsNullOrWhiteSpace(this.Prefixo2) ? "" : this.Prefixo2), "")); + observableCollection.Add(new Tuple("SEGUNDO TELEFONE", (string.IsNullOrWhiteSpace(this.Telefone2) ? "" : this.Telefone2), "")); + observableCollection.Add(new Tuple("EMAIL", (string.IsNullOrWhiteSpace(this.Email) ? "" : this.Email), "")); + observableCollection.Add(new Tuple("ACESSO MOBILE", (this.Mobile ? "SIM" : "NÃO"), "")); + observableCollection.Add(new Tuple("ACESSO RESULTADOS", (this.Resultados ? "SIM" : "NÃO"), "")); + observableCollection.Add(new Tuple("ACESSO INDIVIDUAL AGGILIZADOR", (this.Aggilizador ? "SIM" : "NÃO"), "")); + expedicao = this.InicioAcesso; + if (!expedicao.HasValue) + { + shortTimeString = ""; + } + else + { + expedicao = this.InicioAcesso; + if (expedicao.HasValue) + { + shortTimeString = expedicao.GetValueOrDefault().ToShortTimeString(); + } + else + { + shortTimeString = null; + } + } + observableCollection.Add(new Tuple("INÍCIO DO ACESSO", shortTimeString, "")); + expedicao = this.FimAcesso; + if (!expedicao.HasValue) + { + shortTimeString1 = ""; + } + else + { + expedicao = this.FimAcesso; + if (expedicao.HasValue) + { + shortTimeString1 = expedicao.GetValueOrDefault().ToShortTimeString(); + } + else + { + shortTimeString1 = null; + } + } + observableCollection.Add(new Tuple("FIM DO ACESSO", shortTimeString1, "")); + observableCollection.Add(new Tuple("ADMINISTRADOR CENTRAL SEGURADO", (this.AdministradorCentralSegurado ? "SIM" : "NÃO"), "")); + tupleList.Tuples = observableCollection; + tupleLists.Add(tupleList); + return tupleLists; + } + + public UserSso ToUserSso(string serial, string documentoEmpresa, string ssoId = null) + { + return new UserSso() + { + Id = ssoId, + Name = this.Nome, + Username = this.Login, + Password = this.Senha, + Serial = serial, + CustomerDocument = documentoEmpresa, + IdEmpresa = this.IdEmpresa, + Document = this.Documento, + IsDeleted = false, + Email = this.Email ?? string.Empty, + Phone = (string.IsNullOrEmpty(this.Prefixo) || string.IsNullOrEmpty(this.Telefone) ? string.Empty : string.Concat(this.Prefixo.Clear(), this.Telefone.Clear())) + }; + } + + public List> Validate() + { + List> keyValuePairs = ValidationHelper.AddValue(); + if (this.Expedicao.HasValue && (DateTime.Compare(this.Expedicao.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Expedicao.Value, new DateTime(9999, 12, 31)) > 0)) + { + keyValuePairs.AddValue("Expedicao", string.Format(Messages.DataInvalida, Array.Empty()), true); + } + 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 (this.InicioAcesso.HasValue && this.FimAcesso.HasValue && this.InicioAcesso.Value.TimeOfDay > this.FimAcesso.Value.TimeOfDay) + { + keyValuePairs.AddValue("FimAcesso|FIM DO ACESSO", "O HORÁRIO DO FIM DO ACESSO NÃO PODE SER ANTERIOR AO HORÁRIO DO INICIO DO ACESSO", true); + } + if (string.IsNullOrEmpty(this.Nome)) + { + keyValuePairs.AddValue("Nome", Messages.Obrigatorio, true); + } + else if (this.Nome.Length > 50) + { + keyValuePairs.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 50), true); + } + if (!string.IsNullOrEmpty(this.Documento) && !this.Documento.ValidacaoDocumento()) + { + keyValuePairs.AddValue("Documento", Messages.Invalido, true); + } + if (string.IsNullOrEmpty(this.Login)) + { + keyValuePairs.AddValue("Login", Messages.Obrigatorio, true); + } + else if (this.Login.Length > 30) + { + keyValuePairs.AddValue("Login", string.Format(Messages.MaiorQueLimite, 30), true); + } + if (!string.IsNullOrEmpty(this.Login) && !Regex.IsMatch(this.Login, "^(?!.* {2})[a-zA-Z0-9](?:[a-zA-Z0-9 .]{0,49}[a-zA-Z0-9])?$")) + { + keyValuePairs.AddValue("Login|USUARIO", "USUARIO INVALIDO,\nUSUARIO SOMENTE DEVE CONTER LETRAS E NUMEROS,\nNÃO DEVE CONTER MAIS DE UM ESPAÇO,\nNÃO DEVE TER ESPAÇO NO INICIO E NO FIM.\nEXEMPLO VALIDO:\nUSUARIO01 OU USUARIO 02 OU USUARIO.03", true); + } + if (string.IsNullOrEmpty(this.Senha)) + { + keyValuePairs.AddValue("Senha", Messages.Obrigatorio, true); + } + if (string.IsNullOrEmpty(this.Email)) + { + keyValuePairs.AddValue("Email", Messages.Obrigatorio, true); + } + if (!string.IsNullOrEmpty(this.EstadoEmissor) && !this.EstadoEmissor.ValidacaoEstado()) + { + keyValuePairs.AddValue("EstadoEmissor", Messages.Invalido, true); + } + if (this.Expedicao.HasValue && !this.Expedicao.ValidacaoDataPassada()) + { + keyValuePairs.AddValue("Expedicao", Messages.Invalido, true); + } + if (this.Nascimento.HasValue && !this.Nascimento.ValidacaoDataPassada()) + { + keyValuePairs.AddValue("Nascimento", Messages.Invalido, true); + } + if (!string.IsNullOrEmpty(base.Cep) && !base.Cep.ValidacaoCep()) + { + keyValuePairs.AddValue("Cep", Messages.Invalido, true); + } + if (!string.IsNullOrEmpty(base.Endereco) && base.Endereco.Length > 60) + { + keyValuePairs.AddValue("Endereco", string.Format(Messages.MaiorQueLimite, 60), true); + } + if (!string.IsNullOrEmpty(base.Numero) && base.Numero.Length > 5) + { + keyValuePairs.AddValue("Numero", string.Format(Messages.MaiorQueLimite, 5), true); + } + if (!string.IsNullOrEmpty(base.Bairro) && base.Bairro.Length > 60) + { + keyValuePairs.AddValue("Bairro", string.Format(Messages.MaiorQueLimite, 60), true); + } + if (!string.IsNullOrEmpty(base.Cidade) && base.Cidade.Length > 30) + { + keyValuePairs.AddValue("Cidade", string.Format(Messages.MaiorQueLimite, 30), true); + } + if (!string.IsNullOrEmpty(base.Estado) && !base.Estado.ValidacaoEstado()) + { + keyValuePairs.AddValue("Estado", Messages.Invalido, true); + } + if (!string.IsNullOrEmpty(base.Cep) || !string.IsNullOrEmpty(base.Numero) || !string.IsNullOrEmpty(base.Complemento) || !string.IsNullOrEmpty(base.Endereco) || !string.IsNullOrEmpty(base.Bairro) || !string.IsNullOrEmpty(base.Cidade) || !string.IsNullOrEmpty(base.Estado)) + { + if (string.IsNullOrEmpty(base.Cep)) + { + keyValuePairs.AddValue("Cep", Messages.Obrigatorio, true); + } + if (string.IsNullOrEmpty(base.Endereco)) + { + keyValuePairs.AddValue("Endereco", Messages.Obrigatorio, true); + } + if (string.IsNullOrEmpty(base.Numero)) + { + keyValuePairs.AddValue("Numero", Messages.Obrigatorio, true); + } + if (string.IsNullOrEmpty(base.Bairro)) + { + keyValuePairs.AddValue("Bairro", Messages.Obrigatorio, true); + } + if (string.IsNullOrEmpty(base.Cidade)) + { + keyValuePairs.AddValue("Cidade", Messages.Obrigatorio, true); + } + if (string.IsNullOrEmpty(base.Estado)) + { + keyValuePairs.AddValue("Estado", Messages.Obrigatorio, true); + } + } + if (this.AdministradorCentralSegurado && string.IsNullOrEmpty(this.Documento)) + { + keyValuePairs.AddValue("Documento", Messages.Obrigatorio, true); + } + if (this.AdministradorCentralSegurado && string.IsNullOrEmpty(this.Prefixo)) + { + keyValuePairs.AddValue("Prefixo", Messages.Obrigatorio, true); + } + if (this.AdministradorCentralSegurado && string.IsNullOrEmpty(this.Telefone)) + { + keyValuePairs.AddValue("Telefone", Messages.Obrigatorio, true); + } + if (this.AdministradorCentralSegurado && string.IsNullOrEmpty(this.Email)) + { + keyValuePairs.AddValue("Email", Messages.Obrigatorio, true); + } + if (this.InicioAcesso.HasValue && this.FimAcesso.HasValue && this.FimAcesso.Value.TimeOfDay == this.InicioAcesso.Value.TimeOfDay) + { + keyValuePairs.AddValue("InicioAcesso", Messages.Invalido, true); + keyValuePairs.AddValue("FimAcesso", Messages.Invalido, true); + } + if (this.Documento == null || string.IsNullOrEmpty(this.Documento)) + { + keyValuePairs.AddValue("Documento", Messages.Obrigatorio, true); + } + return keyValuePairs; + } + } +} \ No newline at end of file -- cgit v1.2.3