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

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 this._selectedSaldo;
			}
			set
			{
				if (value != null && !this._telaBancos)
				{
					value.set_DataFinal(null);
					value.set_ValorFinal(null);
				}
				this._selectedSaldo = value;
				base.OnPropertyChanged("SelectedSaldo");
				this.SelectedSaldo.Initialize();
			}
		}

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

		public async Task<List<KeyValuePair<string, string>>> Salvar()
		{
			List<KeyValuePair<string, string>> keyValuePairs;
			List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedSaldo.Validate();
			if (keyValuePairs1.Count <= 0)
			{
				if (!this._telaBancos)
				{
					this.SelectedSaldo.set_DataFinal(null);
					this.SelectedSaldo.set_ValorFinal(null);
				}
				this.SelectedSaldo = await this._saldoServico.Save(this.SelectedSaldo);
				if (this._saldoServico.Sucesso)
				{
					base.Alterar(false);
					base.ToggleSnackBar("SALDO SALVO COM SUCESSO", true);
					keyValuePairs = null;
				}
				else
				{
					keyValuePairs = null;
				}
			}
			else
			{
				keyValuePairs = keyValuePairs1;
			}
			return keyValuePairs;
		}
	}
}