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 Anexos { get; set; } public Ramo Ramo { get; set; } [JsonIgnore] public Func>> ValidationEvent => Validate; public List> Validate() { List> 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 Log() { List list = new List(); TupleList tupleList = new TupleList(); ObservableCollection> obj = new ObservableCollection> { new Tuple("NOME", string.IsNullOrWhiteSpace(Nome) ? "" : Nome, ""), new Tuple("DOCUMENTO", string.IsNullOrWhiteSpace(Documento) ? "" : Documento, ""), new Tuple("NASCIMENTO", (!Nascimento.HasValue) ? "" : Nascimento?.ToShortDateString(), ""), new Tuple("PRIMEIRO PREFIXO", string.IsNullOrWhiteSpace(Prefixo1) ? "" : Prefixo1, ""), new Tuple("PRIMEIRO TELEFONE", string.IsNullOrWhiteSpace(Telefone1) ? "" : Telefone1, ""), new Tuple("SEGUNDO PREFIXO", string.IsNullOrWhiteSpace(Prefixo2) ? "" : Prefixo2, ""), new Tuple("SEGUNDO TELEFONE", string.IsNullOrWhiteSpace(Telefone2) ? "" : Telefone2, ""), new Tuple("E-MAIL", string.IsNullOrWhiteSpace(Email) ? "" : Email, ""), new Tuple("ITEM", string.IsNullOrWhiteSpace(Item) ? "" : Item, ""), new Tuple("PRODUTO", string.IsNullOrWhiteSpace(Produto?.Nome) ? "" : Produto.Nome, ""), new Tuple("VENCIMENTO", (!VigenciaFinal.HasValue) ? "" : VigenciaFinal?.ToShortDateString(), ""), new Tuple("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("STATUS", (string)item, "")); obj.Add(new Tuple("STATUS PERSONALIZADO", (StatusPersonalizado == null) ? "" : StatusPersonalizado.Nome, "")); obj.Add(new Tuple("OBSERVAÇÃO", string.IsNullOrWhiteSpace(Observacao) ? "" : Observacao, "")); tupleList.Tuples = obj; list.Add(tupleList); List list2 = list; if (Tarefa != null) { ObservableCollection> tuples = new ObservableCollection> { new Tuple("TAREFA$", "", ""), new Tuple(" RESPONSÁVEL", string.IsNullOrWhiteSpace(Tarefa.Usuario.Nome) ? "" : Tarefa.Usuario.Nome, ""), new Tuple(" DATA DO AGENDAMENTO", Tarefa.Agendamento.ToShortDateString(), ""), new Tuple(" HORA DO AGENDAMENTO", Tarefa.Agendamento.ToShortTimeString(), "") }; list2.Add(new TupleList { Tuples = tuples }); } return list2; } }