diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
| commit | 0440c722a221b8068bbf388c1c0c51f0faff0451 (patch) | |
| tree | 169cbf90c50ff7961db82ecb606c50c2a45a1688 /Gestor.Model/Gestor.Model.Domain.Seguros/Usuario.cs | |
| parent | 225aa1499e37faf9d38257caabbadc68d78b427e (diff) | |
| download | gestor-0440c722a221b8068bbf388c1c0c51f0faff0451.tar.gz gestor-0440c722a221b8068bbf388c1c0c51f0faff0451.zip | |
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Seguros/Usuario.cs')
| -rw-r--r-- | Gestor.Model/Gestor.Model.Domain.Seguros/Usuario.cs | 625 |
1 files changed, 625 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Seguros/Usuario.cs b/Gestor.Model/Gestor.Model.Domain.Seguros/Usuario.cs new file mode 100644 index 0000000..969b8e6 --- /dev/null +++ b/Gestor.Model/Gestor.Model.Domain.Seguros/Usuario.cs @@ -0,0 +1,625 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Text.RegularExpressions; +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; + +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; + + public long IdEmpresa { get; set; } + + [Log(true)] + public TipoTelaInicial? TelaInicial + { + get + { + return _telaInicial.GetValueOrDefault(); + } + set + { + _telaInicial = value.GetValueOrDefault(); + } + } + + [Log(true)] + [Name(true)] + public string Nome + { + get + { + return _nome; + } + set + { + _nome = value; + } + } + + public bool Selecionado { get; set; } + + [Log(true)] + [Description("DATA DE NASCIMENTO")] + public DateTime? Nascimento { get; set; } + + [Log(true)] + public Sexo Sexo { get; set; } + + [Log(true)] + public string Login + { + get + { + return _login?.ToUpper(); + } + set + { + _login = value; + } + } + + public string SenhaAnterior { get; set; } = string.Empty; + + + public string Senha { get; set; } + + [Log(true)] + [Description("TIPO DO TELEFONE 1")] + public TipoTelefone? TipoTelefone { get; set; } + + [Log(true)] + [Description("PREFIXO TELEFONE 1")] + public string Prefixo + { + get + { + return _prefixo?.ToUpper().Trim(); + } + set + { + _prefixo = value; + } + } + + [Log(true)] + [Description("TELEFONE 1")] + public string Telefone + { + get + { + return _telefone?.ToUpper().Trim(); + } + set + { + _telefone = value; + } + } + + [Log(true)] + [Description("TIPO DO TELEFONE 2")] + public TipoTelefone? TipoTelefone2 { get; set; } + + [Log(true)] + [Description("PREFIXO TELEFONE 2")] + public string Prefixo2 + { + get + { + return _prefixo2?.ToUpper().Trim(); + } + set + { + _prefixo2 = value; + } + } + + [Log(true)] + [Description("TELEFONE 2")] + public string Telefone2 + { + get + { + return _telefone2?.ToUpper().Trim(); + } + set + { + _telefone2 = value; + } + } + + [Log(true)] + public string Email + { + get + { + return _email?.ToLower().Trim(); + } + set + { + _email = value; + } + } + + [Log(true)] + public string Documento + { + get + { + return _documento?.ToUpper().Trim(); + } + set + { + _documento = value; + } + } + + [Log(true)] + public string Identidade + { + get + { + return _identidade?.ToUpper().Trim(); + } + set + { + _identidade = value; + } + } + + [Log(true)] + [Description("ESTADO EMISSOR")] + public string EstadoEmissor + { + get + { + return _estadoEmissor?.ToUpper().Trim(); + } + set + { + _estadoEmissor = value; + } + } + + [Log(true)] + [Description("DATA DE EXPEDIÇÃO")] + public DateTime? Expedicao { get; set; } + + [Log(true)] + public Banco Banco { get; set; } + + [Log(true)] + [Description("AGÊNCIA")] + public string Agencia + { + get + { + return _agencia?.ToUpper().Trim(); + } + set + { + _agencia = value; + } + } + + [Log(true)] + public string Conta + { + get + { + return _conta?.ToUpper().Trim(); + } + set + { + _conta = value; + } + } + + [Log(true)] + [Description("ACESSO AO MOBILE")] + public bool Mobile { get; set; } + + [Log(true)] + [Description("ACESSO AOS RESULTADOS MOBILE")] + public bool Resultados { get; set; } + + public bool Aggilizador { get; set; } + + public bool Excluido { get; set; } + + [Log(true)] + [Description("PERMISSÃO ACESSO AGGILIZADOR")] + public long? PermissaoAggilizador { get; set; } + + [Log(true)] + public bool Administrador { get; set; } + + [Description("INÍCIO DO ACESSO")] + public DateTime? InicioAcesso { get; set; } + + [Description("FIM DO ACESSO")] + public DateTime? FimAcesso { get; set; } + + [Log(true)] + [Description("ACESSO ÀS SEGUNDAS-FEIRAS")] + public bool? Segunda + { + get + { + return _segunda; + } + set + { + _segunda = value.GetValueOrDefault(true); + } + } + + [Log(true)] + [Description("ACESSO ÀS TERÇAS-FEIRAS")] + public bool? Terca + { + get + { + return _terca; + } + set + { + _terca = value.GetValueOrDefault(true); + } + } + + [Log(true)] + [Description("ACESSO ÁS QUARTAS-FEIRAS")] + public bool? Quarta + { + get + { + return _quarta; + } + set + { + _quarta = value.GetValueOrDefault(true); + } + } + + [Log(true)] + [Description("ACESSO ÁS QUINTAS-FEIRAS")] + public bool? Quinta + { + get + { + return _quinta; + } + set + { + _quinta = value.GetValueOrDefault(true); + } + } + + [Log(true)] + [Description("ACESSO ÁS SEXTAS-FEIRAS")] + public bool? Sexta + { + get + { + return _sexta; + } + set + { + _sexta = value.GetValueOrDefault(true); + } + } + + [Log(true)] + [Description("ACESSO AOS SÁBADOS")] + public bool? Sabado + { + get + { + return _sabado; + } + set + { + _sabado = value.GetValueOrDefault(true); + } + } + + [Log(true)] + [Description("ACESSO AOS DOMINGOS")] + public bool? Domingo + { + get + { + return _domingo; + } + set + { + _domingo = value.GetValueOrDefault(true); + } + } + + [Log(true)] + public string Cargo { get; set; } + + public string Visita { get; set; } + + [Log(true)] + [Description("FILTRO INICIAL")] + public TipoFiltroCliente? FiltroInicial { get; set; } + + [Log(true)] + [Description("ACESSO AO DASHBOARD")] + public bool? Dashboard + { + get + { + return _dashboard; + } + set + { + _dashboard = value.GetValueOrDefault(true); + } + } + + [Log(true)] + [Description("PERMISSÃO ADMINISTRADOR CENTRAL SEGURADO")] + public bool AdministradorCentralSegurado { get; set; } + + public string SsoId { get; set; } + + public string TokenSso { get; set; } + + [JsonIgnore] + public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate; + + public UserSso ToUserSso(string serial, string documentoEmpresa, string ssoId = null) + { + return new UserSso + { + Id = ssoId, + Name = Nome, + Username = Login, + Password = Senha, + Serial = serial, + CustomerDocument = documentoEmpresa, + IdEmpresa = IdEmpresa, + Document = Documento, + IsDeleted = false, + Email = (Email ?? string.Empty), + Phone = ((string.IsNullOrEmpty(Prefixo) || string.IsNullOrEmpty(Telefone)) ? string.Empty : (Prefixo.Clear() + Telefone.Clear())) + }; + } + + public List<KeyValuePair<string, string>> Validate() + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + if (Expedicao.HasValue && (DateTime.Compare(Expedicao.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Expedicao.Value, new DateTime(9999, 12, 31)) > 0)) + { + list.AddValue("Expedicao", string.Format(Messages.DataInvalida)); + } + if (Nascimento.HasValue && (DateTime.Compare(Nascimento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Nascimento.Value, new DateTime(9999, 12, 31)) > 0)) + { + list.AddValue("Nascimento", string.Format(Messages.DataInvalida)); + } + if (InicioAcesso.HasValue && FimAcesso.HasValue && InicioAcesso.Value.TimeOfDay > FimAcesso.Value.TimeOfDay) + { + list.AddValue("FimAcesso|FIM DO ACESSO", "O HORÁRIO DO FIM DO ACESSO NÃO PODE SER ANTERIOR AO HORÁRIO DO INICIO DO ACESSO"); + } + if (string.IsNullOrEmpty(Nome)) + { + list.AddValue("Nome", Messages.Obrigatorio); + } + else if (Nome.Length > 50) + { + list.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 50)); + } + if (!string.IsNullOrEmpty(Documento) && !Documento.ValidacaoDocumento()) + { + list.AddValue("Documento", Messages.Invalido); + } + if (string.IsNullOrEmpty(Login)) + { + list.AddValue("Login", Messages.Obrigatorio); + } + else if (Login.Length > 30) + { + list.AddValue("Login", string.Format(Messages.MaiorQueLimite, 30)); + } + if (!string.IsNullOrEmpty(Login) && !Regex.IsMatch(Login, "^(?!.* {2})[a-zA-Z0-9](?:[a-zA-Z0-9 .]{0,49}[a-zA-Z0-9])?$")) + { + list.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"); + } + if (string.IsNullOrEmpty(Senha)) + { + list.AddValue("Senha", Messages.Obrigatorio); + } + if (string.IsNullOrEmpty(Email)) + { + list.AddValue("Email", Messages.Obrigatorio); + } + if (!string.IsNullOrEmpty(EstadoEmissor) && !EstadoEmissor.ValidacaoEstado()) + { + list.AddValue("EstadoEmissor", Messages.Invalido); + } + if (Expedicao.HasValue && !Expedicao.ValidacaoDataPassada()) + { + list.AddValue("Expedicao", Messages.Invalido); + } + if (Nascimento.HasValue && !Nascimento.ValidacaoDataPassada()) + { + list.AddValue("Nascimento", Messages.Invalido); + } + if (!string.IsNullOrEmpty(base.Cep) && !base.Cep.ValidacaoCep()) + { + list.AddValue("Cep", Messages.Invalido); + } + if (!string.IsNullOrEmpty(base.Endereco) && base.Endereco.Length > 60) + { + list.AddValue("Endereco", string.Format(Messages.MaiorQueLimite, 60)); + } + if (!string.IsNullOrEmpty(base.Numero) && base.Numero.Length > 5) + { + list.AddValue("Numero", string.Format(Messages.MaiorQueLimite, 5)); + } + if (!string.IsNullOrEmpty(base.Bairro) && base.Bairro.Length > 60) + { + list.AddValue("Bairro", string.Format(Messages.MaiorQueLimite, 60)); + } + if (!string.IsNullOrEmpty(base.Cidade) && base.Cidade.Length > 30) + { + list.AddValue("Cidade", string.Format(Messages.MaiorQueLimite, 30)); + } + if (!string.IsNullOrEmpty(base.Estado) && !base.Estado.ValidacaoEstado()) + { + list.AddValue("Estado", Messages.Invalido); + } + 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)) + { + list.AddValue("Cep", Messages.Obrigatorio); + } + if (string.IsNullOrEmpty(base.Endereco)) + { + list.AddValue("Endereco", Messages.Obrigatorio); + } + if (string.IsNullOrEmpty(base.Numero)) + { + list.AddValue("Numero", Messages.Obrigatorio); + } + if (string.IsNullOrEmpty(base.Bairro)) + { + list.AddValue("Bairro", Messages.Obrigatorio); + } + if (string.IsNullOrEmpty(base.Cidade)) + { + list.AddValue("Cidade", Messages.Obrigatorio); + } + if (string.IsNullOrEmpty(base.Estado)) + { + list.AddValue("Estado", Messages.Obrigatorio); + } + } + if (AdministradorCentralSegurado && string.IsNullOrEmpty(Documento)) + { + list.AddValue("Documento", Messages.Obrigatorio); + } + if (AdministradorCentralSegurado && string.IsNullOrEmpty(Prefixo)) + { + list.AddValue("Prefixo", Messages.Obrigatorio); + } + if (AdministradorCentralSegurado && string.IsNullOrEmpty(Telefone)) + { + list.AddValue("Telefone", Messages.Obrigatorio); + } + if (AdministradorCentralSegurado && string.IsNullOrEmpty(Email)) + { + list.AddValue("Email", Messages.Obrigatorio); + } + if (InicioAcesso.HasValue && FimAcesso.HasValue && FimAcesso.Value.TimeOfDay == InicioAcesso.Value.TimeOfDay) + { + list.AddValue("InicioAcesso", Messages.Invalido); + list.AddValue("FimAcesso", Messages.Invalido); + } + if (Documento == null || string.IsNullOrEmpty(Documento)) + { + list.AddValue("Documento", Messages.Obrigatorio); + } + return list; + } + + public List<TupleList> Log() + { + return new List<TupleList> + { + new TupleList + { + Tuples = new ObservableCollection<Tuple<string, string, string>> + { + new Tuple<string, string, string>("NOME", string.IsNullOrWhiteSpace(Nome) ? "" : Nome, ""), + new Tuple<string, string, string>("CPF/CNPJ", string.IsNullOrWhiteSpace(Documento) ? "" : Documento, ""), + new Tuple<string, string, string>("USUÁRIO", string.IsNullOrWhiteSpace(Login) ? "" : Login, ""), + new Tuple<string, string, string>("IDENTIDADE", string.IsNullOrWhiteSpace(Identidade) ? "" : Identidade, ""), + new Tuple<string, string, string>("ESTADO EMISSOR", string.IsNullOrWhiteSpace(EstadoEmissor) ? "" : EstadoEmissor, ""), + new Tuple<string, string, string>("DATA DE EXPEDIÇÃO", (!Expedicao.HasValue) ? "" : Expedicao?.ToShortDateString(), ""), + new Tuple<string, string, string>("SEXO", Sexo.GetDescription(), ""), + new Tuple<string, string, string>("DATA DE NASCIMENTO", (!Nascimento.HasValue) ? "" : Nascimento?.ToShortDateString(), ""), + new Tuple<string, string, string>("BANCO", (Banco == null) ? "" : Banco?.Nome, ""), + new Tuple<string, string, string>("AGÊNCIA", string.IsNullOrWhiteSpace(Agencia) ? "" : Agencia, ""), + new Tuple<string, string, string>("CONTA", string.IsNullOrWhiteSpace(Conta) ? "" : Conta, ""), + new Tuple<string, string, string>("ENDEREÇO", string.IsNullOrWhiteSpace(base.Endereco) ? "" : base.Endereco, ""), + new Tuple<string, string, string>("NÚMERO", string.IsNullOrWhiteSpace(base.Numero) ? "" : base.Numero, ""), + new Tuple<string, string, string>("COMPLEMENTO", string.IsNullOrWhiteSpace(base.Complemento) ? "" : base.Complemento, ""), + new Tuple<string, string, string>("BAIRRO", string.IsNullOrWhiteSpace(base.Bairro) ? "" : base.Bairro, ""), + new Tuple<string, string, string>("CIDADE", string.IsNullOrWhiteSpace(base.Cidade) ? "" : base.Cidade, ""), + new Tuple<string, string, string>("ESTADO", string.IsNullOrWhiteSpace(base.Estado) ? "" : base.Estado, ""), + new Tuple<string, string, string>("CEP", string.IsNullOrWhiteSpace(base.Cep) ? "" : base.Cep, ""), + new Tuple<string, string, string>("TIPO TELEFONE", (!TipoTelefone.HasValue) ? "" : TipoTelefone.GetDescription(), ""), + new Tuple<string, string, string>("PRIMEIRO PREFIXO", string.IsNullOrWhiteSpace(Prefixo) ? "" : Prefixo, ""), + new Tuple<string, string, string>("PRIMEIRO TELEFONE", string.IsNullOrWhiteSpace(Telefone) ? "" : Telefone, ""), + new Tuple<string, string, string>("TIPO TELEFONE", (!TipoTelefone2.HasValue) ? "" : TipoTelefone2.GetDescription(), ""), + new Tuple<string, string, string>("SEGUNDO PREFIXO", string.IsNullOrWhiteSpace(Prefixo2) ? "" : Prefixo2, ""), + new Tuple<string, string, string>("SEGUNDO TELEFONE", string.IsNullOrWhiteSpace(Telefone2) ? "" : Telefone2, ""), + new Tuple<string, string, string>("EMAIL", string.IsNullOrWhiteSpace(Email) ? "" : Email, ""), + new Tuple<string, string, string>("ACESSO MOBILE", Mobile ? "SIM" : "NÃO", ""), + new Tuple<string, string, string>("ACESSO RESULTADOS", Resultados ? "SIM" : "NÃO", ""), + new Tuple<string, string, string>("ACESSO INDIVIDUAL AGGILIZADOR", Aggilizador ? "SIM" : "NÃO", ""), + new Tuple<string, string, string>("INÍCIO DO ACESSO", (!InicioAcesso.HasValue) ? "" : InicioAcesso?.ToShortTimeString(), ""), + new Tuple<string, string, string>("FIM DO ACESSO", (!FimAcesso.HasValue) ? "" : FimAcesso?.ToShortTimeString(), ""), + new Tuple<string, string, string>("ADMINISTRADOR CENTRAL SEGURADO", AdministradorCentralSegurado ? "SIM" : "NÃO", "") + } + } + }; + } +} |