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
|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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;
namespace Gestor.Model.Domain.Ferramentas;
public class Agenda : DomainBase, IDomain
{
public string Nome { get; set; }
public string Endereco { get; set; }
public string Cep { get; set; }
public string Numero { get; set; }
public string Complemento { get; set; }
public string Bairro { get; set; }
public string Cidade { get; set; }
public string Estado { get; set; }
public string Observacao { get; set; }
public ObservableCollection<AgendaTelefone> Telefones { get; set; }
public ObservableCollection<AgendaEmail> Emails { get; set; }
[JsonIgnore]
public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate;
public List<KeyValuePair<string, string>> Validate()
{
List<KeyValuePair<string, string>> list = ValidationHelper.AddValue();
if (string.IsNullOrWhiteSpace(Nome))
{
list.AddValue("Nome", Messages.Obrigatorio);
}
return list;
}
public List<TupleList> Log()
{
List<TupleList> list = new List<TupleList>();
list.Add(new TupleList
{
Tuples = new ObservableCollection<Tuple<string, string, string>>
{
new Tuple<string, string, string>("NOME", string.IsNullOrWhiteSpace(Nome) ? "" : Nome, ""),
new Tuple<string, string, string>("CEP", string.IsNullOrWhiteSpace(Cep) ? "" : Cep, ""),
new Tuple<string, string, string>("ENDEREÇO", string.IsNullOrWhiteSpace(Endereco) ? "" : Endereco, ""),
new Tuple<string, string, string>("NÚMERO", string.IsNullOrWhiteSpace(Numero) ? "" : Numero, ""),
new Tuple<string, string, string>("COMPLEMENTO", string.IsNullOrWhiteSpace(Complemento) ? "" : Complemento, ""),
new Tuple<string, string, string>("BAIRRO", string.IsNullOrWhiteSpace(Bairro) ? "" : Bairro, ""),
new Tuple<string, string, string>("CIDADE", string.IsNullOrWhiteSpace(Cidade) ? "" : Cidade, ""),
new Tuple<string, string, string>("ESTADO", string.IsNullOrWhiteSpace(Estado) ? "" : Estado, ""),
new Tuple<string, string, string>("OBSERVAÇÕES", string.IsNullOrWhiteSpace(Observacao) ? "" : Observacao, "")
}
});
ObservableCollection<Tuple<string, string, string>> observableCollection = new ObservableCollection<Tuple<string, string, string>>
{
new Tuple<string, string, string>("TELEFONES$", "", "")
};
foreach (AgendaTelefone telefone in Telefones)
{
observableCollection.Add(new Tuple<string, string, string>($" TELEFONE {Telefones.IndexOf(telefone) + 1}$", "", ""));
object item;
if (telefone.Tipo.HasValue)
{
TipoTelefone? tipo = telefone.Tipo;
item = (tipo.HasValue ? tipo.GetValueOrDefault().GetDescription() : null);
}
else
{
item = "";
}
observableCollection.Add(new Tuple<string, string, string>(" TIPO", (string)item, ""));
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, ""));
}
list.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 Emails)
{
observableCollection2.Add(new Tuple<string, string, string>($" EMAIL {Emails.IndexOf(email) + 1}$", "", ""));
observableCollection2.Add(new Tuple<string, string, string>(" ENDEREÇO DE EMAIL", string.IsNullOrWhiteSpace(email.Email) ? "" : email.Email, ""));
}
list.Add(new TupleList
{
Tuples = observableCollection2
});
return list;
}
}
|