summaryrefslogtreecommitdiff
path: root/Gestor.Model/Gestor.Model.Domain.Seguros/Prospeccao.cs
blob: 613fddc3d7c7395ac40a5d40f62294c850e313cb (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using Gestor.Model.Attributes;
using Gestor.Model.Common;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Helper;
using Gestor.Model.Resources;
using Gestor.Model.Validation;
using Newtonsoft.Json;

namespace Gestor.Model.Domain.Seguros;

public class Prospeccao : DomainBase, IDomain
{
	private string _nome;

	private string _item;

	private string _observacao;

	public long IdEmpresa { get; set; }

	[Description("CLIENTE")]
	public string Nome
	{
		get
		{
			return _nome?.ToUpper();
		}
		set
		{
			_nome = value;
		}
	}

	[Description("DOCUMENTO")]
	public string Documento { get; set; }

	[Tipo("DATA?")]
	[Description("NASCIMENTO")]
	public DateTime? Nascimento { get; set; }

	[Description("DDD")]
	public string Prefixo1 { get; set; }

	[Description("TELEFONE")]
	public string Telefone1 { get; set; }

	[Description("DDD")]
	public string Prefixo2 { get; set; }

	[Description("TELEFONE")]
	public string Telefone2 { get; set; }

	[Description("E-MAIL")]
	public string Email { get; set; }

	[Tipo("DATA?")]
	[Description("VIGÊNCIA FINAL")]
	public DateTime? VigenciaFinal { get; set; }

	[Description("ITEM")]
	public string Item
	{
		get
		{
			return _item?.ToUpper();
		}
		set
		{
			_item = value;
		}
	}

	public Vendedor Vendedor { get; set; }

	[Tipo("ENUM?")]
	[Description("STATUS")]
	public StatusProspeccao? Status { get; set; }

	[Description("STATUS PERSONALIZADO")]
	public StatusDeProspeccao StatusPersonalizado { get; set; }

	[Description("TIPO")]
	public string Tipo { get; set; }

	[Description("VALOR")]
	public decimal Valor { get; set; }

	public string Observacao
	{
		get
		{
			return _observacao?.ToUpper();
		}
		set
		{
			_observacao = value;
		}
	}

	public bool Excluido { get; set; }

	public Tarefa Tarefa { get; set; }

	public bool CriarTarefa { get; set; }

	public bool AbrirTarefa { get; set; }

	public bool Renovacao { get; set; }

	public DateTime? DataCriacao { get; set; }

	public long UsuarioCriacao { get; set; }

	public Produto Produto { get; set; }

	public List<ArquivoDigital> Anexos { get; set; }

	public Ramo Ramo { 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 (Nascimento.HasValue && (DateTime.Compare(Nascimento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Nascimento.Value, new DateTime(9999, 12, 31)) > 0))
		{
			list.AddValue("Nascimento", string.Format(Messages.DataInvalida));
		}
		if (VigenciaFinal.HasValue && (DateTime.Compare(VigenciaFinal.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(VigenciaFinal.Value, new DateTime(9999, 12, 31)) > 0))
		{
			list.AddValue("VigenciaFinal|VENCIMENTO", string.Format(Messages.DataInvalida));
		}
		if (string.IsNullOrWhiteSpace(Nome))
		{
			list.AddValue("Nome", Messages.Obrigatorio);
		}
		if (string.IsNullOrWhiteSpace(Telefone1) && string.IsNullOrWhiteSpace(Telefone2) && string.IsNullOrWhiteSpace(Email))
		{
			list.AddValue("Telefone1|TELEFONE 1", Messages.Obrigatorio);
		}
		if (!VigenciaFinal.HasValue)
		{
			list.AddValue("VigenciaFinal|VENCIMENTO", Messages.Obrigatorio);
		}
		if (string.IsNullOrWhiteSpace(Item))
		{
			list.AddValue("Item", Messages.Obrigatorio);
		}
		return list;
	}

	public List<TupleList> Log()
	{
		List<TupleList> list = new List<TupleList>();
		TupleList tupleList = new TupleList();
		ObservableCollection<Tuple<string, string, string>> obj = new ObservableCollection<Tuple<string, string, string>>
		{
			new Tuple<string, string, string>("NOME", string.IsNullOrWhiteSpace(Nome) ? "" : Nome, ""),
			new Tuple<string, string, string>("DOCUMENTO", string.IsNullOrWhiteSpace(Documento) ? "" : Documento, ""),
			new Tuple<string, string, string>("NASCIMENTO", (!Nascimento.HasValue) ? "" : Nascimento?.ToShortDateString(), ""),
			new Tuple<string, string, string>("PRIMEIRO PREFIXO", string.IsNullOrWhiteSpace(Prefixo1) ? "" : Prefixo1, ""),
			new Tuple<string, string, string>("PRIMEIRO TELEFONE", string.IsNullOrWhiteSpace(Telefone1) ? "" : Telefone1, ""),
			new Tuple<string, string, string>("SEGUNDO PREFIXO", string.IsNullOrWhiteSpace(Prefixo2) ? "" : Prefixo2, ""),
			new Tuple<string, string, string>("SEGUNDO TELEFONE", string.IsNullOrWhiteSpace(Telefone2) ? "" : Telefone2, ""),
			new Tuple<string, string, string>("E-MAIL", string.IsNullOrWhiteSpace(Email) ? "" : Email, ""),
			new Tuple<string, string, string>("ITEM", string.IsNullOrWhiteSpace(Item) ? "" : Item, ""),
			new Tuple<string, string, string>("PRODUTO", string.IsNullOrWhiteSpace(Produto?.Nome) ? "" : Produto.Nome, ""),
			new Tuple<string, string, string>("VENCIMENTO", (!VigenciaFinal.HasValue) ? "" : VigenciaFinal?.ToShortDateString(), ""),
			new Tuple<string, string, string>("VENDEDOR", string.IsNullOrWhiteSpace(Vendedor?.Nome) ? "" : Vendedor.Nome, "")
		};
		object item;
		if (Status.HasValue)
		{
			StatusProspeccao? status = Status;
			item = (status.HasValue ? status.GetValueOrDefault().GetDescription() : null);
		}
		else
		{
			item = "";
		}
		obj.Add(new Tuple<string, string, string>("STATUS", (string)item, ""));
		obj.Add(new Tuple<string, string, string>("STATUS PERSONALIZADO", (StatusPersonalizado == null) ? "" : StatusPersonalizado.Nome, ""));
		obj.Add(new Tuple<string, string, string>("OBSERVAÇÃO", string.IsNullOrWhiteSpace(Observacao) ? "" : Observacao, ""));
		tupleList.Tuples = obj;
		list.Add(tupleList);
		List<TupleList> list2 = list;
		if (Tarefa != null)
		{
			ObservableCollection<Tuple<string, string, string>> tuples = new ObservableCollection<Tuple<string, string, string>>
			{
				new Tuple<string, string, string>("TAREFA$", "", ""),
				new Tuple<string, string, string>("      RESPONSÁVEL", string.IsNullOrWhiteSpace(Tarefa.Usuario.Nome) ? "" : Tarefa.Usuario.Nome, ""),
				new Tuple<string, string, string>("      DATA DO AGENDAMENTO", Tarefa.Agendamento.ToShortDateString(), ""),
				new Tuple<string, string, string>("      HORA DO AGENDAMENTO", Tarefa.Agendamento.ToShortTimeString(), "")
			};
			list2.Add(new TupleList
			{
				Tuples = tuples
			});
		}
		return list2;
	}
}