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.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.Financeiro; public class Planos : DomainBase, IDomain { private string _descricao; private Sinal _sinal; private string _nome; public bool Selecionado { get; set; } [Log(true)] [Name(true)] [Description("DESCRIÇÃO")] public string Descricao { get { return _descricao?.ToUpper(); } set { _descricao = value; string text = ((Sinal == Sinal.Credito) ? "(+)" : "(-)"); Nome = value.ToUpper() + " " + text; } } [Log(true)] public string Nome { get { return _nome.ToUpper(); } set { _nome = value; } } [Log(true)] [Description("TIPO CONTA")] public TipoConta TipoConta { get; set; } [Log(true)] public bool Ativo { get; set; } [Log(true)] public Sinal Sinal { get { return _sinal; } set { _sinal = value; string text = ((value == Sinal.Credito) ? "(+)" : "(-)"); Nome = Descricao + " " + text; } } [Log(true)] public Plano Plano { get; set; } [JsonIgnore] public Func>> ValidationEvent => Validate; public List> Validate() { List> list = ValidationHelper.AddValue(); if (string.IsNullOrWhiteSpace(Descricao)) { list.AddValue("Descricao", Messages.Obrigatorio); } if (Plano == null) { list.AddValue("Plano", 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("PLANO", (Plano == null) ? "" : Plano?.Descricao, ""), new Tuple("ATIVO", Ativo ? "SIM" : "NÃO", "") }; _ = Sinal; obj.Add(new Tuple("SINAL", Sinal.GetDescription(), "")); tupleList.Tuples = obj; list.Add(tupleList); return list; } }