1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
using System;
using System.Collections.Generic;
using Gestor.Model.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Helper;
using Gestor.Model.Resources;
using Newtonsoft.Json;
namespace Gestor.Model.Domain.Seguros;
public class Perfil : DomainBase, IDomain
{
private string _nome;
private string _cepCirculacao;
private string _cepPernoite;
public Cliente Cliente { get; set; }
public Controle Controle { get; set; }
public bool? UsoProfissional { get; set; }
public bool? SeguroVida { get; set; }
public Antifurto? AntiFurto { get; set; }
public bool? EstenderCobertura { get; set; }
public int? VeiculoResidencia { get; set; }
public string Cpf { get; set; }
public string Habilitacao { get; set; }
public DateTime? Nascimento { get; set; }
public string Nome
{
get
{
return _nome?.ToUpper();
}
set
{
_nome = value;
}
}
public Relacao? Relacao { get; set; }
public GaragemTrabalhoEstudo? GaragemTrabalho { get; set; }
public GaragemTrabalhoEstudo? GaragemEstudo { get; set; }
public GaragemResidencia? GaragemResidencia { get; set; }
public TipoResidencia? TipoResidencia { get; set; }
public UsoDependetes? UsoDependentes { get; set; }
public DistanciaTrabalho? DistanciaResidenciaTrabalho { get; set; }
public Ocupacao? Ocupacao { get; set; }
public Sexo? Sexo { get; set; }
public TempoHabilitacao? TempoHabilitacao { get; set; }
public EstadoCivil? EstadoCivil { get; set; }
public string KmMensal { get; set; }
public string CepPernoite
{
get
{
return _cepPernoite;
}
set
{
_cepPernoite = value;
}
}
public string CepCirculacao
{
get
{
return _cepCirculacao;
}
set
{
_cepCirculacao = value;
}
}
public bool? Isencao { get; set; }
[JsonIgnore]
public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate;
public List<KeyValuePair<string, string>> Validate()
{
List<KeyValuePair<string, string>> list = ValidationHelper.AddValue();
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 (string.IsNullOrWhiteSpace(Nome))
{
list.AddValue("Nome", Messages.Obrigatorio);
}
else if (Nome.Length > 255)
{
list.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 255));
}
string kmMensal = KmMensal;
if (kmMensal != null && kmMensal.Length > 5)
{
list.AddValue("KmMensal", string.Format(Messages.MaiorQueLimite, 5));
}
string habilitacao = Habilitacao;
if (habilitacao != null && habilitacao.Length > 15)
{
list.AddValue("Habilitacao", string.Format(Messages.MaiorQueLimite, 15));
}
if (!Relacao.HasValue)
{
list.AddValue("Relacao", Messages.Obrigatorio);
}
if (!string.IsNullOrWhiteSpace(Cpf) && !Cpf.ValidacaoDocumento())
{
list.AddValue("Cpf", Messages.Invalido);
}
if (!string.IsNullOrWhiteSpace(CepPernoite) && !CepPernoite.FormataCep().ValidacaoCep())
{
list.AddValue("CepPernoite", Messages.Invalido);
}
if (!string.IsNullOrWhiteSpace(CepCirculacao) && !CepCirculacao.FormataCep().ValidacaoCep())
{
list.AddValue("CepCirculacao", Messages.Invalido);
}
return list;
}
}
|