summaryrefslogtreecommitdiff
path: root/Gestor.Model/Model.Domain.Ferramentas/Agenda.cs
blob: 263f0bc22ba4e303fe0705edb35a64e9556e6503 (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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
using Gestor.Model.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
using Gestor.Model.Helper;
using Gestor.Model.Resources;
using Gestor.Model.Validation;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;

namespace Gestor.Model.Domain.Ferramentas
{
	public class Agenda : DomainBase, IDomain
	{
		public string Bairro
		{
			get;
			set;
		}

		public string Cep
		{
			get;
			set;
		}

		public string Cidade
		{
			get;
			set;
		}

		public string Complemento
		{
			get;
			set;
		}

		public ObservableCollection<AgendaEmail> Emails
		{
			get;
			set;
		}

		public string Endereco
		{
			get;
			set;
		}

		public string Estado
		{
			get;
			set;
		}

		public string Nome
		{
			get;
			set;
		}

		public string Numero
		{
			get;
			set;
		}

		public string Observacao
		{
			get;
			set;
		}

		public ObservableCollection<AgendaTelefone> Telefones
		{
			get;
			set;
		}

		[JsonIgnore]
		public Func<List<KeyValuePair<string, string>>> ValidationEvent
		{
			get
			{
				Agenda agenda = this;
				return new Func<List<KeyValuePair<string, string>>>(agenda.Validate);
			}
		}

		public Agenda()
		{
		}

		public List<TupleList> Log()
		{
			string description;
			List<TupleList> tupleLists = new List<TupleList>()
			{
				new TupleList()
				{
					Tuples = new ObservableCollection<Tuple<string, string, string>>()
					{
						new Tuple<string, string, string>("NOME", (string.IsNullOrWhiteSpace(this.Nome) ? "" : this.Nome), ""),
						new Tuple<string, string, string>("CEP", (string.IsNullOrWhiteSpace(this.Cep) ? "" : this.Cep), ""),
						new Tuple<string, string, string>("ENDEREÇO", (string.IsNullOrWhiteSpace(this.Endereco) ? "" : this.Endereco), ""),
						new Tuple<string, string, string>("NÚMERO", (string.IsNullOrWhiteSpace(this.Numero) ? "" : this.Numero), ""),
						new Tuple<string, string, string>("COMPLEMENTO", (string.IsNullOrWhiteSpace(this.Complemento) ? "" : this.Complemento), ""),
						new Tuple<string, string, string>("BAIRRO", (string.IsNullOrWhiteSpace(this.Bairro) ? "" : this.Bairro), ""),
						new Tuple<string, string, string>("CIDADE", (string.IsNullOrWhiteSpace(this.Cidade) ? "" : this.Cidade), ""),
						new Tuple<string, string, string>("ESTADO", (string.IsNullOrWhiteSpace(this.Estado) ? "" : this.Estado), ""),
						new Tuple<string, string, string>("OBSERVAÇÕES", (string.IsNullOrWhiteSpace(this.Observacao) ? "" : this.Observacao), "")
					}
				}
			};
			ObservableCollection<Tuple<string, string, string>> observableCollection = new ObservableCollection<Tuple<string, string, string>>()
			{
				new Tuple<string, string, string>("TELEFONES$", "", "")
			};
			foreach (AgendaTelefone telefone in this.Telefones)
			{
				observableCollection.Add(new Tuple<string, string, string>(string.Format("   TELEFONE {0}$", this.Telefones.IndexOf(telefone) + 1), "", ""));
				ObservableCollection<Tuple<string, string, string>> observableCollection1 = observableCollection;
				TipoTelefone? tipo = telefone.Tipo;
				if (!tipo.HasValue)
				{
					description = "";
				}
				else
				{
					tipo = telefone.Tipo;
					if (tipo.HasValue)
					{
						description = tipo.GetValueOrDefault().GetDescription();
					}
					else
					{
						description = null;
					}
				}
				observableCollection1.Add(new Tuple<string, string, string>("      TIPO", description, ""));
				observableCollection.Add(new Tuple<string, string, string>("      PREFIXO", (string.IsNullOrWhiteSpace(telefone.Prefixo) ? "" : telefone.Prefixo.ToUpper()), ""));
				observableCollection.Add(new Tuple<string, string, string>("      NÚMERO", (string.IsNullOrWhiteSpace(telefone.Numero) ? "" : telefone.Numero), ""));
				observableCollection.Add(new Tuple<string, string, string>("      DESCRIÇÃO", (string.IsNullOrWhiteSpace(telefone.Observacao) ? "" : telefone.Observacao), ""));
			}
			tupleLists.Add(new TupleList()
			{
				Tuples = observableCollection
			});
			ObservableCollection<Tuple<string, string, string>> observableCollection2 = new ObservableCollection<Tuple<string, string, string>>()
			{
				new Tuple<string, string, string>("EMAILS$", "", "")
			};
			foreach (AgendaEmail email in this.Emails)
			{
				observableCollection2.Add(new Tuple<string, string, string>(string.Format("   EMAIL {0}$", this.Emails.IndexOf(email) + 1), "", ""));
				observableCollection2.Add(new Tuple<string, string, string>("      ENDEREÇO DE EMAIL", (string.IsNullOrWhiteSpace(email.Email) ? "" : email.Email), ""));
			}
			tupleLists.Add(new TupleList()
			{
				Tuples = observableCollection2
			});
			return tupleLists;
		}

		public List<KeyValuePair<string, string>> Validate()
		{
			List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
			if (string.IsNullOrWhiteSpace(this.Nome))
			{
				keyValuePairs.AddValue<string, string>("Nome", Messages.Obrigatorio, true);
			}
			return keyValuePairs;
		}
	}
}