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
|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Seguros.Itens;
using Gestor.Application.ViewModels.Generic;
using Gestor.Application.ViewModels.Seguros;
using Gestor.Common.Validation;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
namespace Gestor.Application.ViewModels;
public class CoberturaViewModel : BaseSegurosViewModel
{
private readonly ItemServico _itemServico;
private Cobertura _selectedCobertura = new Cobertura();
private List<CoberturaPadrao> _coberturasPadrao;
private ObservableCollection<Cobertura> _coberturas;
private readonly IComparer<Cobertura> _comparerCobertura = Comparer<Cobertura>.Create(delegate(Cobertura item1, Cobertura item2)
{
if (((DomainBase)item1).Id > ((DomainBase)item2).Id)
{
return 1;
}
return (((DomainBase)item1).Id < ((DomainBase)item2).Id) ? (-1) : 0;
});
public Item Item { get; set; }
public Ramo Ramo { get; set; }
public Cobertura SelectedCobertura
{
get
{
return _selectedCobertura;
}
set
{
_selectedCobertura = value;
OnPropertyChanged("SelectedCobertura");
}
}
public List<CoberturaPadrao> CoberturasPadrao
{
get
{
return _coberturasPadrao;
}
set
{
_coberturasPadrao = value;
OnPropertyChanged("CoberturasPadrao");
}
}
public ObservableCollection<Cobertura> Coberturas
{
get
{
return _coberturas;
}
set
{
_coberturas = value;
OnPropertyChanged("Coberturas");
}
}
public CoberturaViewModel(Ramo ramo = null, Item item = null)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Item = item ?? ConsultaViewModel.ItemSelecionado;
object obj = ramo;
if (obj == null)
{
Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado;
if (documentoSelecionado == null)
{
obj = null;
}
else
{
Controle controle = documentoSelecionado.Controle;
obj = ((controle != null) ? controle.Ramo : null);
}
}
Ramo = (Ramo)obj;
_itemServico = new ItemServico();
}
public async Task SelectionaCoberturas()
{
if (Ramo != null)
{
CoberturasPadrao = Recursos.Coberturas.Where((CoberturaPadrao x) => x.IdRamo == ((DomainBase)Ramo).Id).ToList();
if (Item != null)
{
Coberturas = await _itemServico.BuscarCoberturasPorItemAsync(((DomainBase)Item).Id);
}
}
}
internal async Task<List<CoberturaPadrao>> BuscarCobertura(string value)
{
return await Task.Run(() => CoberturasPadrao?.Where((CoberturaPadrao x) => ValidationHelper.RemoveDiacritics(x.Descricao.ToUpper().Trim()).Contains(value.ToUpper())).ToList());
}
public void AdicionaCobertura()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
Cobertura val = new Cobertura
{
Item = Item
};
ValidationHelper.AddSorted<Cobertura>(Coberturas, val, _comparerCobertura);
SelectedCobertura = val;
}
public async void ExcluirCobertura(Cobertura cobertura)
{
if (cobertura != null && await ShowMessage("DESEJA REALMENTE EXCLUIR A COBERTURA" + Environment.NewLine + "\"" + cobertura.Observacao + "\"?", "SIM", "NÃO"))
{
Coberturas.Remove(cobertura);
}
}
public async Task<IList<Cobertura>> LimpaCoberturas()
{
bool flag = Coberturas != null && Coberturas.Any((Cobertura x) => x.Franquia == 0m && x.Lmi == 0m && x.Premio == 0m);
if (flag)
{
flag = await ShowMessage("DESEJA LIMPAR AS COBERTURAS SEM VALOR DE FRANQUIA, LMI E PRÊMIO?", "SIM", "NÃO");
}
return (!flag) ? Coberturas?.ToList() : Coberturas?.Where((Cobertura x) => !string.IsNullOrEmpty(x.Observacao) && (x.Franquia != 0m || x.Lmi != 0m || x.Premio != 0m)).ToList();
}
public async Task CancelarAlteracao()
{
if (Item != null)
{
Coberturas = await _itemServico.BuscarCoberturasPorItemAsync(((DomainBase)Item).Id);
}
}
public void CarregaPadrao()
{
List<Cobertura> list = CoberturasPadrao?.Where((CoberturaPadrao x) => x.Padrao).Select((Func<CoberturaPadrao, Cobertura>)((CoberturaPadrao x) => new Cobertura
{
CoberturaPadrao = x,
Observacao = x.Descricao
})).ToList();
if (list != null)
{
Coberturas = new ObservableCollection<Cobertura>(list);
}
}
public ObservableCollection<Cobertura> CarregaCoberturaPadrao()
{
List<Cobertura> list = CoberturasPadrao?.Where((CoberturaPadrao x) => x.Padrao).Select((Func<CoberturaPadrao, Cobertura>)((CoberturaPadrao x) => new Cobertura
{
CoberturaPadrao = x,
Observacao = x.Descricao
})).ToList();
return Coberturas = new ObservableCollection<Cobertura>(list);
}
}
|