diff options
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Seguros/TitularesVida.cs')
| -rw-r--r-- | Gestor.Model/Gestor.Model.Domain.Seguros/TitularesVida.cs | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Seguros/TitularesVida.cs b/Gestor.Model/Gestor.Model.Domain.Seguros/TitularesVida.cs new file mode 100644 index 0000000..6ec26af --- /dev/null +++ b/Gestor.Model/Gestor.Model.Domain.Seguros/TitularesVida.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using Gestor.Model.Common; +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 TitularesVida : DomainBase, IDomain, INotifyPropertyChanged +{ + private string _codigo; + + private string _fatura; + + private string _nome; + + private string _observacao; + + private string _matricula; + + private decimal? _premio; + + private decimal? _capital; + + private bool _selecionado; + + public bool Selecionado + { + get + { + return _selecionado; + } + set + { + if (value != _selecionado) + { + _selecionado = value; + OnPropertyChanged("Selecionado"); + } + } + } + + public long IdItem { get; set; } + + public string Codigo + { + get + { + return _codigo?.ToUpper(); + } + set + { + _codigo = value; + } + } + + public DateTime? Inicio { get; set; } + + public DateTime? Fim { get; set; } + + public string Fatura + { + get + { + return _fatura?.ToUpper(); + } + set + { + _fatura = value; + } + } + + public string Nome + { + get + { + return _nome?.ToUpper(); + } + set + { + _nome = value; + } + } + + public string Observacao + { + get + { + return _observacao?.ToUpper(); + } + set + { + _observacao = value; + } + } + + public DateTime? Nascimento { get; set; } + + public string Cpf { get; set; } + + public string Matricula + { + get + { + return _matricula?.ToUpper(); + } + set + { + _matricula = value; + } + } + + public decimal? Premio + { + get + { + return _premio.GetValueOrDefault(); + } + set + { + _premio = value; + } + } + + public decimal? Capital + { + get + { + return _capital.GetValueOrDefault(); + } + set + { + _capital = value; + } + } + + public TipoTitular? Tipo { get; set; } + + public TitularesVida Dependente { get; set; } + + [JsonIgnore] + public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + public List<KeyValuePair<string, string>> Validate() + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + if (string.IsNullOrWhiteSpace(Nome)) + { + list.AddValue("Nome", Messages.Obrigatorio); + } + else if (Nome.Length > 150) + { + list.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 150)); + } + if (!Inicio.HasValue) + { + list.AddValue("Inicio|INÍCIO", Messages.Obrigatorio); + } + else if (DateTime.Compare(Inicio.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Inicio.Value, new DateTime(9999, 12, 31)) > 0) + { + list.AddValue("Inicio|INÍCIO", string.Format(Messages.DataInvalida)); + } + if (Fim.HasValue && (DateTime.Compare(Fim.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Fim.Value, new DateTime(9999, 12, 31)) > 0)) + { + list.AddValue("Fim", string.Format(Messages.DataInvalida)); + } + 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 ((!Nascimento.HasValue || Funcoes.GetAge(Nascimento.Value) >= 18) && !string.IsNullOrWhiteSpace(Cpf) && !Cpf.ValidacaoDocumento()) + { + list.AddValue("Cpf", Messages.Invalido); + } + if (!Tipo.HasValue) + { + list.AddValue("Tipo", Messages.Obrigatorio); + } + if (Tipo.GetValueOrDefault() == TipoTitular.Dependente && Dependente == null) + { + list.AddValue("Dependente", "OBRIGATÓRIO. PESQUISE POR UM DOS TITULARES\nQUE SEJA DO TIPO SÓCIO OU FUNCIONÁRIO"); + } + return list; + } +} |