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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
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 Item : DomainBase, IDomain, INotifyPropertyChanged
{
private bool _selecionado;
private string _descricao;
private string _status;
private string _statusInclusao;
private string _observacao;
private string _valorCredito;
private bool _config = true;
private bool _fabricanteBranco;
public bool Selecionado
{
get
{
return _selecionado;
}
set
{
if (value != _selecionado)
{
_selecionado = value;
OnPropertyChanged("Selecionado");
}
}
}
public Documento Documento { get; set; }
public long? Substituido { get; set; }
public long? Substituicao { get; set; }
public long? Endosso { get; set; }
public int? Ordem { get; set; }
public long? IdDocumentoCancelado { get; set; }
public string Descricao
{
get
{
return _descricao?.ToUpper();
}
set
{
_descricao = value;
}
}
public bool Cancelado { get; set; }
public bool Sinistrado { get; set; }
public TipoEndosso? TipoEndosso { get; set; }
public string Status
{
get
{
return _status?.ToUpper();
}
set
{
_status = value;
}
}
public string StatusInclusao
{
get
{
return _statusInclusao?.ToUpper();
}
set
{
_statusInclusao = value;
}
}
public string Observacao
{
get
{
return _observacao?.ToUpper();
}
set
{
_observacao = value;
}
}
public IList<ControleSinistro> Sinistros { get; set; }
public IList<Cobertura> Coberturas { get; set; }
public Auto Auto { get; set; }
public Patrimonial Patrimonial { get; set; }
public Aeronautico Aeronautico { get; set; }
public RiscosDiversos RiscosDiversos { get; set; }
public Granizo Granizo { get; set; }
public Vida Vida { get; set; }
public Sinistro Sinistro { get; set; }
public Consorcio Consorcio { get; set; }
public IList<TitularesVida> Titulares { get; set; }
[JsonIgnore]
public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public List<KeyValuePair<string, string>> Validate(bool config, bool fabricanteBranco = false)
{
_config = config;
_fabricanteBranco = fabricanteBranco;
return Validate();
}
public List<KeyValuePair<string, string>> Validate()
{
List<KeyValuePair<string, string>> list = ValidationHelper.AddValue();
if (!Ordem.HasValue || Ordem == 0)
{
list.AddValue("Ordem", Messages.Invalido);
}
if (string.IsNullOrWhiteSpace(Descricao))
{
list.AddValue("Descricao", Messages.Obrigatorio);
}
else if (Descricao.Length > 250)
{
list.AddValue("Descricao", string.Format(Messages.MaiorQueLimite, 250));
}
if (Documento == null)
{
return list;
}
long id = Documento.Controle.Ramo.Id;
if (id <= 38)
{
long num = id - 1;
if ((ulong)num <= 19uL)
{
switch (num)
{
case 4L:
goto IL_0184;
case 0L:
case 1L:
case 2L:
case 14L:
case 17L:
goto IL_01c5;
case 12L:
goto IL_022f;
case 19L:
goto IL_0264;
case 5L:
case 6L:
case 8L:
case 9L:
goto IL_0299;
case 3L:
case 7L:
case 10L:
case 11L:
case 13L:
case 15L:
case 16L:
case 18L:
goto IL_03f1;
}
}
long num2 = id - 30;
if ((ulong)num2 <= 8uL)
{
switch (num2)
{
case 7L:
break;
case 0L:
goto IL_01c5;
case 8L:
goto IL_01fa;
case 1L:
goto IL_033d;
case 6L:
goto IL_03c2;
default:
goto IL_03f1;
}
goto IL_0184;
}
}
else if (id == 47 || id == 53 || id == 66)
{
goto IL_0299;
}
goto IL_03f1;
IL_0264:
if (Granizo == null)
{
list.AddValue("Granizo", Messages.Obrigatorio);
}
else
{
list.AddRange(Granizo.Validate());
}
goto IL_041e;
IL_01fa:
if (Patrimonial == null)
{
list.AddValue("Patrimonial", Messages.Obrigatorio);
}
else
{
list.AddRange(Patrimonial.ValidateGarantia());
}
goto IL_041e;
IL_01c5:
if (Patrimonial == null)
{
list.AddValue("Patrimonial", Messages.Obrigatorio);
}
else
{
list.AddRange(Patrimonial.Validate());
}
goto IL_041e;
IL_03f1:
if (RiscosDiversos == null)
{
list.AddValue("RiscosDiversos", Messages.Obrigatorio);
}
else
{
list.AddRange(RiscosDiversos.Validate());
}
goto IL_041e;
IL_033d:
if (RiscosDiversos == null)
{
list.AddValue("RiscosDiversos", Messages.Obrigatorio);
}
else
{
list.AddRange(RiscosDiversos.Validate());
}
if (Titulares != null && Titulares.Count > 0)
{
foreach (TitularesVida titulare in Titulares)
{
list.AddRange(titulare.Validate());
}
}
goto IL_041e;
IL_03c2:
if (Consorcio == null)
{
list.AddValue("Consorcio", Messages.Obrigatorio);
}
else
{
list.AddRange(Consorcio.Validate());
}
goto IL_041e;
IL_0299:
if (Vida == null)
{
list.AddValue("Vida", Messages.Obrigatorio);
}
else
{
list.AddRange(Vida.Validate());
}
if (Titulares != null && Titulares.Count > 0 && Documento.Controle.Ramo.Id != 6)
{
foreach (TitularesVida titulare2 in Titulares)
{
list.AddRange(titulare2.Validate());
}
}
goto IL_041e;
IL_041e:
return list;
IL_022f:
if (Aeronautico == null)
{
list.AddValue("Aeronautico", Messages.Obrigatorio);
}
else
{
list.AddRange(Aeronautico.Validate());
}
goto IL_041e;
IL_0184:
if (Auto == null)
{
list.AddValue("Auto", Messages.Obrigatorio);
}
else
{
list.AddRange(Auto.Validate(_config, _fabricanteBranco));
}
goto IL_041e;
}
}
|