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
|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Gestor.Application.Servicos.Seguros;
using Gestor.Application.ViewModels.Generic;
using Gestor.Model.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
namespace Gestor.Application.ViewModels.Seguros;
public class PerfilViewModel : BaseViewModel
{
private readonly PerfilServico _servico;
private readonly Controle _controle;
public long CancelPerfil;
private Perfil _selectedPerfil = new Perfil();
private ObservableCollection<Perfil> _perfis;
public Perfil SelectedPerfil
{
get
{
return _selectedPerfil;
}
set
{
_selectedPerfil = value;
if (value != null && ((DomainBase)value).Id > 0)
{
CancelPerfil = ((DomainBase)value).Id;
}
VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
OnPropertyChanged("SelectedPerfil");
}
}
public ObservableCollection<Perfil> Perfis
{
get
{
return _perfis;
}
set
{
_perfis = value;
OnPropertyChanged("Perfis");
}
}
public PerfilViewModel(Controle controle)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
_servico = new PerfilServico();
_controle = controle;
Seleciona(((DomainBase)controle).Id);
}
private async void Seleciona(long id)
{
Loading(isLoading: true);
await PermissaoTela((TipoTela)32);
await SelecionaPerfis(id, 0L);
Loading(isLoading: false);
}
private async Task SelecionaPerfis(long id, long perfilId = 0L)
{
Loading(isLoading: true);
Perfis = new ObservableCollection<Perfil>(await _servico.BuscarPerfis(id));
SelectedPerfil = (Perfil)((perfilId == 0L) ? ((object)Perfis.FirstOrDefault()) : ((object)Perfis.First((Perfil x) => ((DomainBase)x).Id == perfilId)));
Loading(isLoading: false);
}
public void Incluir()
{
//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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
Perfil selectedPerfil = new Perfil
{
Controle = _controle,
Cliente = _controle.Cliente,
UsoProfissional = false,
AntiFurto = (Antifurto)0,
Isencao = false,
SeguroVida = false,
EstenderCobertura = false
};
SelectedPerfil = selectedPerfil;
Alterar(alterar: true);
}
public async Task<List<KeyValuePair<string, string>>> Salvar()
{
List<KeyValuePair<string, string>> list = SelectedPerfil.Validate();
if (list.Count > 0)
{
return list;
}
SelectedPerfil = await _servico.Save(SelectedPerfil);
if (!_servico.Sucesso)
{
return null;
}
await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)SelectedPerfil).Id);
ToggleSnackBar("PERFIL SALVO COM SUCESSO");
Alterar(alterar: false);
return null;
}
public void CancelarAlteracao()
{
Loading(isLoading: true);
if (CancelPerfil > 0)
{
SelectedPerfil = ((IEnumerable<Perfil>)Perfis).FirstOrDefault((Func<Perfil, bool>)((Perfil x) => ((DomainBase)x).Id == CancelPerfil));
}
Alterar(alterar: false);
Loading(isLoading: false);
}
public async Task Excluir()
{
if (SelectedPerfil == null || ((DomainBase)SelectedPerfil).Id == 0L || !(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
{
return;
}
Loading(isLoading: true);
bool isLast = SelectedPerfil == Perfis.Last();
if (!(await _servico.Delete(SelectedPerfil)))
{
Loading(isLoading: false);
return;
}
if (isLast)
{
int num = Perfis.IndexOf(SelectedPerfil);
if (num <= 0)
{
await SelecionaPerfis(((DomainBase)_controle).Id, 0L);
}
else
{
await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)Perfis[num - 1]).Id);
}
}
else if (Perfis.Count > 0)
{
await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)Perfis[Perfis.IndexOf(SelectedPerfil) + 1]).Id);
}
Loading(isLoading: false);
ToggleSnackBar("PERFIL EXCLUÍDO COM SUCESSO");
}
}
|