summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Ferramentas/QualificacaoViewModel.cs
blob: 5e79531b834e85de0223a3e29b438563bc791b87 (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
using System.Collections.Generic;
using System.Threading.Tasks;
using Gestor.Application.Servicos.Ferramentas;
using Gestor.Application.ViewModels.Generic;
using Gestor.Model.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;

namespace Gestor.Application.ViewModels.Ferramentas;

public class QualificacaoViewModel : BaseSegurosViewModel
{
	private readonly QualificacaoServico _servico;

	private Qualificacao _selectedQualificacao;

	public Qualificacao CancelQualificacao;

	public Qualificacao SelectedQualificacao
	{
		get
		{
			return _selectedQualificacao;
		}
		set
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			if (value == null || ((DomainBase)value).Id == 0L)
			{
				value = new Qualificacao
				{
					Liquido1 = 0m,
					Liquido2 = 1000m,
					Liquido3 = 5000m,
					Comissao1 = 10m,
					Comissao2 = 15m,
					Comissao3 = 20m,
					Resultado1 = 100m,
					Resultado2 = 200m,
					Resultado3 = 300m,
					Id = 1L
				};
			}
			_selectedQualificacao = value;
			VerificarEnables(((DomainBase)value).Id);
			OnPropertyChanged("SelectedQualificacao");
		}
	}

	public QualificacaoViewModel()
	{
		_servico = new QualificacaoServico();
		Seleciona();
	}

	private async void Seleciona()
	{
		Loading(isLoading: true);
		await PermissaoTela((TipoTela)48);
		await SelecionaQualificacao();
		Loading(isLoading: false);
	}

	private async Task SelecionaQualificacao()
	{
		Loading(isLoading: true);
		SelectedQualificacao = await _servico.BuscarQualificacaoAsync();
		RegistrarAcao("ACESSOU QUALIFICAÇÃO", 0L, (TipoTela)48);
		Loading(isLoading: false);
	}

	public async Task<List<KeyValuePair<string, string>>> Salvar()
	{
		if (((DomainBase)(await _servico.BuscarQualificacaoAsync())).Id == 0L)
		{
			((DomainBase)SelectedQualificacao).Id = 0L;
		}
		List<KeyValuePair<string, string>> list = SelectedQualificacao.Validate();
		if (list.Count > 0)
		{
			return list;
		}
		SelectedQualificacao = await _servico.Save(SelectedQualificacao);
		if (!_servico.Sucesso)
		{
			return null;
		}
		RegistrarAcao("ALTEROU QUALIFICAÇÃO", 0L, (TipoTela)48);
		Alterar(alterar: false);
		ToggleSnackBar("QUALIFICACAO SALVA COM SUCESSO");
		return null;
	}

	public void CancelarAlteracao()
	{
		Loading(isLoading: true);
		if (((DomainBase)SelectedQualificacao).Id == 0L)
		{
			SelectedQualificacao = null;
			Alterar(alterar: false);
			base.EnableMenu = false;
			Loading(isLoading: false);
		}
		else
		{
			SelectedQualificacao = CancelQualificacao;
		}
		Alterar(alterar: false);
		Loading(isLoading: false);
	}
}