summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Financeiro/InfoExtratoViewModel.cs
blob: 1cf33dccfa65717b65dcb947e556ecb29eaef23d (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
using System.Collections.Generic;
using System.Threading.Tasks;
using Gestor.Application.Servicos.Financeiro;
using Gestor.Application.ViewModels.Generic;
using Gestor.Model.Domain.Financeiro;
using Gestor.Model.Domain.Generic;

namespace Gestor.Application.ViewModels.Financeiro;

public class InfoExtratoViewModel : BaseFinanceiroViewModel
{
	private readonly BancosContasServico _saldoServico;

	private Saldo _selectedSaldo;

	public bool _telaBancos { get; set; }

	public Saldo SelectedSaldo
	{
		get
		{
			return _selectedSaldo;
		}
		set
		{
			if (value != null && !_telaBancos)
			{
				value.DataFinal = null;
				value.ValorFinal = null;
			}
			_selectedSaldo = value;
			OnPropertyChanged("SelectedSaldo");
			((DomainBase)SelectedSaldo).Initialize();
		}
	}

	public InfoExtratoViewModel(bool telaBancos)
	{
		_telaBancos = telaBancos;
		_saldoServico = new BancosContasServico();
	}

	public async Task<List<KeyValuePair<string, string>>> Salvar()
	{
		List<KeyValuePair<string, string>> list = SelectedSaldo.Validate();
		if (list.Count > 0)
		{
			return list;
		}
		if (!_telaBancos)
		{
			SelectedSaldo.DataFinal = null;
			SelectedSaldo.ValorFinal = null;
		}
		SelectedSaldo = await _saldoServico.Save(SelectedSaldo);
		if (!_saldoServico.Sucesso)
		{
			return null;
		}
		Alterar(alterar: false);
		ToggleSnackBar("SALDO SALVO COM SUCESSO");
		return null;
	}
}