summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/BoletosNotasViewModel.cs
blob: 6f2e2502b71d1bee90f8e8c2c1ed54768b9af8b6 (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 Gestor.Application.Model.Ajuda;
using Gestor.Application.Servicos.Ajuda;
using Gestor.Application.ViewModels.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Gestor.Application.ViewModels.Drawer.Ajuda
{
	public class BoletosNotasViewModel : BaseViewModel
	{
		private readonly AjudaServico _ajudaServico;

		private bool _carregando;

		private List<Boleto> _boletos;

		private string _boletoDisponivel;

		private List<string> _status;

		public string BoletoDisponivel
		{
			get
			{
				return this._boletoDisponivel;
			}
			set
			{
				this._boletoDisponivel = value;
				base.OnPropertyChanged("BoletoDisponivel");
			}
		}

		public List<Boleto> Boletos
		{
			get
			{
				return this._boletos;
			}
			set
			{
				this._boletos = value;
				base.OnPropertyChanged("Boletos");
			}
		}

		public bool Carregando
		{
			get
			{
				return this._carregando;
			}
			set
			{
				this._carregando = value;
				base.IsEnabled = !value;
				base.EnableMenu = !value;
				base.OnPropertyChanged("Carregando");
			}
		}

		public List<string> Status
		{
			get
			{
				return this._status;
			}
			set
			{
				this._status = value;
				base.OnPropertyChanged("Status");
			}
		}

		public BoletosNotasViewModel()
		{
			this._ajudaServico = new AjudaServico();
			this.LoadCombos();
			this.BoletoDisponivel = "Disponível para impressão a partir de\n10 (dez) dias antes do vencimento";
		}

		private void LoadCombos()
		{
			this.Status = new List<string>()
			{
				"PENDENTES",
				"BAIXADOS"
			};
		}

		public async void WorkOnSelectedStatus(string value)
		{
			List<Boleto> list;
			this.Carregando = true;
			this.Boletos = new List<Boleto>();
			List<Boleto> boletos = await this._ajudaServico.BuscarBoletosNotas(value);
			BoletosNotasViewModel boletosNotasViewModel = this;
			if (value == "BAIXADOS")
			{
				List<Boleto> boletos1 = boletos;
				IEnumerable<Boleto> hasValue = 
					from x in boletos1
					where x.Pagamento.HasValue
					select x;
				list = (
					from x in hasValue
					orderby x.Pagamento descending
					select x).ToList<Boleto>();
			}
			else
			{
				list = boletos;
			}
			boletosNotasViewModel.Boletos = list;
			this.Carregando = false;
		}
	}
}