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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
using System;
using System.Collections.Generic;
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 Newtonsoft.Json;
namespace Gestor.Model.Domain.Seguros;
public class MaisContato : DomainBase, IDomain
{
private string _nome;
private string _documento;
private string _identidade;
private string _prefixo;
private string _telefone;
private string _email;
private string _habilitacao;
private string _banco;
private string _agencia;
private string _conta;
public Cliente Cliente { get; set; }
public TipoTelefone? Tipo { get; set; }
[Log(true)]
public string Nome
{
get
{
return _nome?.ToUpper();
}
set
{
_nome = value;
}
}
[Log(true)]
public DateTime? Nascimento { get; set; }
[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)]
public DateTime? Expedicao { get; set; }
[Log(true)]
public Parentesco? Parentesco { get; set; }
[Log(true)]
public string Prefixo
{
get
{
return _prefixo?.ToUpper().Trim();
}
set
{
_prefixo = value;
}
}
[Log(true)]
public string Telefone
{
get
{
return _telefone?.ToUpper().Trim();
}
set
{
_telefone = value;
}
}
[Log(true)]
public string Email
{
get
{
return _email?.ToLower().Trim();
}
set
{
_email = value;
}
}
[Log(true)]
public string Habilitacao
{
get
{
return _habilitacao?.ToUpper().Trim();
}
set
{
_habilitacao = value;
}
}
[Log(true)]
public DateTime? PrimeiraHabilitacao { get; set; }
[Log(true)]
public Profissao Profissao { get; set; }
public string Banco
{
get
{
return _banco?.ToUpper();
}
set
{
_banco = value;
}
}
[Log(true)]
public string Agencia
{
get
{
return _agencia?.ToUpper().Trim();
}
set
{
_agencia = value;
}
}
[Log(true)]
public string Conta
{
get
{
return _conta?.ToUpper().Trim();
}
set
{
_conta = value;
}
}
public bool Excluido { 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 (!string.IsNullOrWhiteSpace(Nome) && Nome.Length > 90)
{
list.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 90));
}
if (PrimeiraHabilitacao.HasValue && (DateTime.Compare(PrimeiraHabilitacao.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(PrimeiraHabilitacao.Value, new DateTime(9999, 12, 31)) > 0))
{
list.AddValue("PrimeiraHabilitacao|PRIMEIRA HABILITAÇÃO", string.Format(Messages.DataInvalida));
}
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|EXPEDIÇÃO", 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 (!string.IsNullOrWhiteSpace(Documento) && Documento.Length > 30)
{
list.AddValue("Documento", string.Format(Messages.MaiorQueLimite, 30));
}
if (!string.IsNullOrWhiteSpace(Identidade) && Identidade.Length > 40)
{
list.AddValue("Identidade", string.Format(Messages.MaiorQueLimite, 40));
}
if (!string.IsNullOrWhiteSpace(Prefixo) && Prefixo.Length > 6)
{
list.AddValue("Prefixo", string.Format(Messages.MaiorQueLimite, 6));
}
if (!string.IsNullOrWhiteSpace(Telefone) && Telefone.Length > 11)
{
list.AddValue("Telefone", string.Format(Messages.MaiorQueLimite, 11));
}
if (!string.IsNullOrWhiteSpace(Email) && Email.Length > 80)
{
list.AddValue("Email|E-MAIL", string.Format(Messages.MaiorQueLimite, 80));
}
if (!string.IsNullOrWhiteSpace(Habilitacao) && Habilitacao.Length > 40)
{
list.AddValue("Habilitacao|HABILITAÇÃO", string.Format(Messages.MaiorQueLimite, 40));
}
if (!string.IsNullOrWhiteSpace(Banco) && Banco.Length > 15)
{
list.AddValue("Banco", string.Format(Messages.MaiorQueLimite, 15));
}
if (!string.IsNullOrWhiteSpace(Agencia) && Agencia.Length > 15)
{
list.AddValue("Agencia|AGÊNCIA", string.Format(Messages.MaiorQueLimite, 15));
}
if (!string.IsNullOrWhiteSpace(Conta) && Conta.Length > 20)
{
list.AddValue("Conta", string.Format(Messages.MaiorQueLimite, 20));
}
return list;
}
}
|