blob: d4633e7bc059c9dfcca48a48edff0d1e56ce4fd6 (
plain)
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
|
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.Drawer;
public class ExpedicaoViewModel : BaseSegurosViewModel
{
private readonly ExpedicaoServico _servico;
private readonly Documento _documento;
private bool _carregando;
private Expedicao _selectedExpedicao = new Expedicao();
private ObservableCollection<Expedicao> _expedicoes = new ObservableCollection<Expedicao>();
public bool Carregando
{
get
{
return _carregando;
}
set
{
_carregando = value;
base.EnableMenu = !value;
OnPropertyChanged("Carregando");
}
}
public Expedicao SelectedExpedicao
{
get
{
return _selectedExpedicao;
}
set
{
_selectedExpedicao = value;
VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
OnPropertyChanged("SelectedExpedicao");
}
}
public ObservableCollection<Expedicao> Expedicoes
{
get
{
return _expedicoes;
}
set
{
_expedicoes = value;
OnPropertyChanged("Expedicoes");
}
}
public ExpedicaoViewModel(Documento documento)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
_servico = new ExpedicaoServico();
_documento = documento;
Seleciona(documento);
}
private async void Seleciona(Documento documento)
{
Carregando = true;
await PermissaoTela((TipoTela)46);
await Carregar(documento);
if (Expedicoes.Count > 0)
{
SelectedExpedicao = Expedicoes.First();
}
else
{
SelectedExpedicao = new Expedicao();
Alterar(alterar: false);
base.EnableMenu = false;
}
Carregando = false;
}
private async Task Carregar(Documento documento)
{
Expedicoes = new ObservableCollection<Expedicao>(await _servico.BuscarExpedicoes(documento));
}
public void Incluir()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
SelectedExpedicao = new Expedicao
{
Apolice = _documento
};
Alterar(alterar: true);
}
public async Task<List<KeyValuePair<string, string>>> Salvar()
{
SelectedExpedicao = await _servico.Save(SelectedExpedicao);
if (!_servico.Sucesso)
{
return null;
}
long id = ((DomainBase)SelectedExpedicao).Id;
await Carregar(SelectedExpedicao.Apolice);
SelectedExpedicao = ((IEnumerable<Expedicao>)Expedicoes).FirstOrDefault((Func<Expedicao, bool>)((Expedicao x) => ((DomainBase)x).Id == id));
Alterar(alterar: false);
return null;
}
public async void CancelarAlteracao()
{
Carregando = true;
long id = ((DomainBase)SelectedExpedicao).Id;
await Carregar(SelectedExpedicao.Apolice);
SelectedExpedicao = (Expedicao)((Expedicoes.Count > 0 && id > 0) ? ((IEnumerable<Expedicao>)Expedicoes).FirstOrDefault((Func<Expedicao, bool>)((Expedicao x) => ((DomainBase)x).Id == id)) : ((Expedicoes.Count > 0 && id == 0L) ? ((object)Expedicoes.First()) : ((object)new Expedicao())));
Alterar(alterar: false);
Carregando = false;
}
public async Task<bool> Excluir()
{
if (SelectedExpedicao == null || ((DomainBase)SelectedExpedicao).Id == 0L)
{
return false;
}
if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
{
return false;
}
Carregando = true;
if (!(await _servico.Delete(SelectedExpedicao)))
{
Carregando = false;
return false;
}
int num = Expedicoes.IndexOf(SelectedExpedicao);
Expedicoes.Remove(SelectedExpedicao);
if (Expedicoes.Count > 0)
{
SelectedExpedicao = ((num < Expedicoes.Count) ? Expedicoes.ElementAt(num) : Expedicoes.Last());
}
else
{
SelectedExpedicao = new Expedicao();
}
Carregando = false;
return true;
}
}
|